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
@@ -5,27 +5,13 @@ Test module for custom context processors.
|
||||
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
from django.urls import resolve
|
||||
|
||||
from plinth import context_processors as cp
|
||||
from plinth import menu as menu_module
|
||||
|
||||
|
||||
@pytest.fixture(name='menu', autouse=True)
|
||||
def fixture_menu():
|
||||
"""Initialized menu module."""
|
||||
menu_module.Menu._all_menus = set()
|
||||
menu_module.init()
|
||||
menu_module.Menu('home-id', name='Home', url_name='index')
|
||||
menu_module.Menu('apps-id', name='Apps', url_name='apps',
|
||||
parent_url_name='index')
|
||||
menu_module.Menu('testapp-id', name='Test App', url_name='testapp:index',
|
||||
parent_url_name='apps')
|
||||
|
||||
|
||||
@patch('plinth.notification.Notification')
|
||||
def test_common(Notification, load_cfg, rf):
|
||||
def test_common(Notification, load_cfg, rf, test_menu):
|
||||
"""Verify that the common() function returns the correct values."""
|
||||
url = '/apps/testapp/create/'
|
||||
request = rf.get(url)
|
||||
|
||||
Reference in new issue
Block a user