mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
ui: Handle and show most page load errors as alerts
- In addition to the OperationalError, also handle all generic exceptions during page submit and page load. Redirect to the same page or parent using breadcrumbs. - Log exceptions handled by common error middleware so that they are also part of the system logs. - Update kiwix test as needed. - Refactor some test code that is setting up the menu items. Tests: - When an error occurs during form POST, the same page is show but with an error message. - When an error occurs in an app page during GET, the browser is redirected to the parent section. - When an error occurs in apps page during GET, the browser is redirected to the home page. - When an error occurs in home page during GET, the error is not handled and default 500 handle is triggered. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
1 parent
59a0a3b25f
commit
407fccba2f
7 files changed
+97
-44
No files matched your search
@@ -20,9 +20,7 @@ from django.conf import settings
|
||||
from django.http import Http404
|
||||
from django.urls import re_path
|
||||
|
||||
from plinth import cfg
|
||||
from plinth import menu as menu_module
|
||||
from plinth import module_loader
|
||||
from plinth import cfg, module_loader
|
||||
from plinth.modules import help as help_module
|
||||
from plinth.modules.help import views
|
||||
|
||||
@@ -57,9 +55,8 @@ def fixture_developer_configuration():
|
||||
|
||||
|
||||
@pytest.fixture(name='menu', autouse=True)
|
||||
def fixture_menu():
|
||||
def fixture_menu(test_menu):
|
||||
"""Initialized menu module."""
|
||||
menu_module.init()
|
||||
help_module.HelpApp() # Create all menu components
|
||||
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
Test module for Kiwix views.
|
||||
"""
|
||||
|
||||
from unittest.mock import call, patch, MagicMock
|
||||
from unittest.mock import MagicMock, call, patch
|
||||
|
||||
import pytest
|
||||
from django import urls
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.contrib.messages.storage.fallback import FallbackStorage
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.http.response import Http404
|
||||
|
||||
from plinth import module_loader
|
||||
@@ -94,7 +94,8 @@ def test_add_package_failed(add_package, add_package_request):
|
||||
views.AddPackageView.as_view())
|
||||
assert response.status_code == 302
|
||||
assert response.url == urls.reverse('kiwix:index')
|
||||
assert list(messages)[0].message == 'Failed to add content package.'
|
||||
assert list(messages)[0].message.startswith(
|
||||
'Failed to add content package.')
|
||||
|
||||
|
||||
@patch('plinth.app.App.get')
|
||||
|
||||
Reference in new issue
Block a user