From 8808e203ce40650c0d4a46fafb8d881625a39f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 16 Jul 2024 14:28:08 +0200 Subject: [PATCH] chg: Make categories admin only, use bootstrap5 classes in form --- website/web/__init__.py | 7 ++- website/web/templates/tree.html | 81 +++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 31 deletions(-) diff --git a/website/web/__init__.py b/website/web/__init__.py index e5a837d9..2b084368 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -661,6 +661,7 @@ def historical_lookups(tree_uuid: str) -> str | WerkzeugResponse | Response: @app.route('/tree//categories_capture/', defaults={'query': ''}, methods=['GET', 'POST']) @app.route('/tree//categories_capture/', methods=['GET']) +@flask_login.login_required # type: ignore[misc] def categories_capture(tree_uuid: str, query: str) -> str | WerkzeugResponse | Response: if not enable_categorization: return redirect(url_for('tree', tree_uuid=tree_uuid)) @@ -671,8 +672,8 @@ def categories_capture(tree_uuid: str, query: str) -> str | WerkzeugResponse | R categories = [] possible_ctgs = { 'legitimate': ["parking-page", "default-page", 'institution', 'captcha', 'authentication-form', 'adult-content', 'shop'], - 'malicious': ['clone', 'phishing', 'captcha', 'authentication-form', 'adult-content', 'shop'], - 'unclear': ['captcha', 'authentication-form', 'adult-content', 'shop'] + 'malicious': ['clone', 'phishing', 'captcha', 'authentication-form', 'adult-content', 'shop'], + 'unclear': ['captcha', 'authentication-form', 'adult-content', 'shop'] } if status in possible_ctgs.keys(): lookyloo.categorize_capture(tree_uuid, status) @@ -695,6 +696,7 @@ def categories_capture(tree_uuid: str, query: str) -> str | WerkzeugResponse | R @app.route('/tree//uncategorize/', defaults={'category': ''}) @app.route('/tree//uncategorize/', methods=['GET']) +@flask_login.login_required # type: ignore[misc] def uncategorize_capture(tree_uuid: str, category: str) -> str | WerkzeugResponse | Response: if not enable_categorization: return jsonify({'response': 'Categorization not enabled.'}) @@ -704,6 +706,7 @@ def uncategorize_capture(tree_uuid: str, category: str) -> str | WerkzeugRespons @app.route('/tree//categorize/', defaults={'category': ''}) @app.route('/tree//categorize/', methods=['GET']) +@flask_login.login_required # type: ignore[misc] def categorize_capture(tree_uuid: str, category: str) -> str | WerkzeugResponse | Response: if not enable_categorization: return jsonify({'response': 'Categorization not enabled.'}) diff --git a/website/web/templates/tree.html b/website/web/templates/tree.html index 5f9b7085..1a0a22d7 100644 --- a/website/web/templates/tree.html +++ b/website/web/templates/tree.html @@ -484,7 +484,7 @@