From a3cb409749d4b65f0dd974254f972eced7319a22 Mon Sep 17 00:00:00 2001 From: Gregoo Date: Thu, 30 Jan 2025 09:33:54 +0100 Subject: [PATCH] Rename checkox_error --- bricktracker/views/admin/admin.py | 1 + bricktracker/views/admin/checkbox.py | 22 ++++++++++++++++++---- templates/admin/checkbox.html | 3 +-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/bricktracker/views/admin/admin.py b/bricktracker/views/admin/admin.py index 5d6a4e4..d5586ea 100644 --- a/bricktracker/views/admin/admin.py +++ b/bricktracker/views/admin/admin.py @@ -82,6 +82,7 @@ def admin() -> str: 'admin.html', configuration=BrickConfigurationList.list(), brickset_checkboxes=brickset_checkboxes, + checkbox_error=request.args.get('checkbox_error'), database_counters=database_counters, database_error=request.args.get('database_error'), database_exception=database_exception, diff --git a/bricktracker/views/admin/checkbox.py b/bricktracker/views/admin/checkbox.py index 1dd58bb..134c886 100644 --- a/bricktracker/views/admin/checkbox.py +++ b/bricktracker/views/admin/checkbox.py @@ -27,7 +27,12 @@ admin_checkbox_page = Blueprint( # Add a checkbox @admin_checkbox_page.route('/add', methods=['POST']) @login_required -@exception_handler(__file__, post_redirect='admin.admin', open_checkbox=True) +@exception_handler( + __file__, + post_redirect='admin.admin', + error_name='checkbox_error', + open_checkbox=True +) def add() -> Response: BrickSetCheckbox().from_form(request.form).insert() @@ -45,14 +50,18 @@ def delete(*, id: str) -> str: 'admin.html', delete_checkbox=True, checkbox=BrickSetCheckbox().select_specific(id), - error=request.args.get('error') + error=request.args.get('checkbox_error') ) # Actually delete the checkbox @admin_checkbox_page.route('/delete', methods=['POST']) @login_required -@exception_handler(__file__, post_redirect='admin_checkbox.delete') +@exception_handler( + __file__, + post_redirect='admin_checkbox.delete', + error_name='checkbox_error' +) def do_delete(*, id: str) -> Response: checkbox = BrickSetCheckbox().select_specific(id) checkbox.delete() @@ -88,7 +97,12 @@ def update_status(*, id: str, name: str) -> Response: # Rename the checkbox @admin_checkbox_page.route('/rename', methods=['POST']) @login_required -@exception_handler(__file__, post_redirect='admin.admin', open_checkbox=True) +@exception_handler( + __file__, + post_redirect='admin.admin', + error_name='checkbox_error', + open_checkbox=True +) def rename(*, id: str) -> Response: checkbox = BrickSetCheckbox().select_specific(id) checkbox.from_form(request.form).rename() diff --git a/templates/admin/checkbox.html b/templates/admin/checkbox.html index dbe5360..0ba484a 100644 --- a/templates/admin/checkbox.html +++ b/templates/admin/checkbox.html @@ -1,8 +1,7 @@ {% import 'macro/accordion.html' as accordion %} {{ accordion.header('Checkboxes', 'checkbox', 'admin', expanded=open_checkbox, icon='checkbox-line', class='p-0') }} -{% if error %}{% endif %} -{% if database_error %}{% endif %} +{% if checkbox_error %}{% endif %}
    {% if brickset_checkboxes | length %} {% for checkbox in brickset_checkboxes %}