chg: Make categories admin only, use bootstrap5 classes in form

pull/926/head
Raphaël Vinot 2024-07-16 14:28:08 +02:00
parent fb50cddc8f
commit 8808e203ce
2 changed files with 57 additions and 31 deletions

View File

@ -661,6 +661,7 @@ def historical_lookups(tree_uuid: str) -> str | WerkzeugResponse | Response:
@app.route('/tree/<string:tree_uuid>/categories_capture/', defaults={'query': ''}, methods=['GET', 'POST']) @app.route('/tree/<string:tree_uuid>/categories_capture/', defaults={'query': ''}, methods=['GET', 'POST'])
@app.route('/tree/<string:tree_uuid>/categories_capture/<string:query>', methods=['GET']) @app.route('/tree/<string:tree_uuid>/categories_capture/<string:query>', methods=['GET'])
@flask_login.login_required # type: ignore[misc]
def categories_capture(tree_uuid: str, query: str) -> str | WerkzeugResponse | Response: def categories_capture(tree_uuid: str, query: str) -> str | WerkzeugResponse | Response:
if not enable_categorization: if not enable_categorization:
return redirect(url_for('tree', tree_uuid=tree_uuid)) return redirect(url_for('tree', tree_uuid=tree_uuid))
@ -695,6 +696,7 @@ def categories_capture(tree_uuid: str, query: str) -> str | WerkzeugResponse | R
@app.route('/tree/<string:tree_uuid>/uncategorize/', defaults={'category': ''}) @app.route('/tree/<string:tree_uuid>/uncategorize/', defaults={'category': ''})
@app.route('/tree/<string:tree_uuid>/uncategorize/<string:category>', methods=['GET']) @app.route('/tree/<string:tree_uuid>/uncategorize/<string:category>', methods=['GET'])
@flask_login.login_required # type: ignore[misc]
def uncategorize_capture(tree_uuid: str, category: str) -> str | WerkzeugResponse | Response: def uncategorize_capture(tree_uuid: str, category: str) -> str | WerkzeugResponse | Response:
if not enable_categorization: if not enable_categorization:
return jsonify({'response': 'Categorization not enabled.'}) return jsonify({'response': 'Categorization not enabled.'})
@ -704,6 +706,7 @@ def uncategorize_capture(tree_uuid: str, category: str) -> str | WerkzeugRespons
@app.route('/tree/<string:tree_uuid>/categorize/', defaults={'category': ''}) @app.route('/tree/<string:tree_uuid>/categorize/', defaults={'category': ''})
@app.route('/tree/<string:tree_uuid>/categorize/<string:category>', methods=['GET']) @app.route('/tree/<string:tree_uuid>/categorize/<string:category>', methods=['GET'])
@flask_login.login_required # type: ignore[misc]
def categorize_capture(tree_uuid: str, category: str) -> str | WerkzeugResponse | Response: def categorize_capture(tree_uuid: str, category: str) -> str | WerkzeugResponse | Response:
if not enable_categorization: if not enable_categorization:
return jsonify({'response': 'Categorization not enabled.'}) return jsonify({'response': 'Categorization not enabled.'})

View File

@ -484,7 +484,7 @@
<div id="extra-menu" class="dropdown"> <div id="extra-menu" class="dropdown">
<button class="dropbtn">Extras</button> <button class="dropbtn">Extras</button>
<div id="extra-menu-content" class="dropdown-content"> <div id="extra-menu-content" class="dropdown-content">
{% if enable_categorization %} {% if enable_categorization and current_user.is_authenticated %}
<a href="#categoriesModal" data-remote="{{ url_for('categories_capture', tree_uuid=tree_uuid) }}" <a href="#categoriesModal" data-remote="{{ url_for('categories_capture', tree_uuid=tree_uuid) }}"
data-bs-toggle="modal" data-bs-target="#categoriesModal" role="button">Manage categories</a> data-bs-toggle="modal" data-bs-target="#categoriesModal" role="button">Manage categories</a>
{% endif %} {% endif %}
@ -1109,47 +1109,70 @@
... loading the categorization options ... ... loading the categorization options ...
</div> </div>
<p> <p>
<form id="fast-categories" class="fast-categories"> <form role="form" id="fast-categories" class="fast-categories">
<fieldset id="verification-status"> <fieldset id="verification-status">
<input type="radio" id="legitimate" name="verification-status" value="legitimate"> <div class="form-check form-check-inline">
<label for="legitimate">legitimate</label> <input class="form-check-input" type="radio" id="legitimate" name="verification-status" value="legitimate">
<input type="radio" id="malicious" name="verification-status" value="malicious"> <label class="form-check-label" for="legitimate">legitimate</label>
<label for="malicious">malicious</label> </div>
<input type="radio" id="unclear" name="verification-status" value="unclear"> <div class="form-check form-check-inline">
<label for="unclear">unclear</label> <input class="form-check-input" type="radio" id="malicious" name="verification-status" value="malicious">
<label class="form-check-label" for="malicious">malicious</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="unclear" name="verification-status" value="unclear" checked>
<label class="form-check-label" for="unclear">unclear</label>
</div>
</fieldset> </fieldset>
<div id="content-categoies"> <div id="content-categoies">
<p>Content Categories (Multiple Choices possible)</p> <p>Content Categories (Multiple Choices possible)</p>
<fieldset id="legitimate-categories"> <fieldset id="legitimate-categories" hidden>
<p>Only if legitimate:</p> <p>Only if legitimate:</p>
<input type="checkbox" id="parking-page" name="parking-page" value="parking-page"> <div class="form-check">
<label for="parking-page">parking-page</label><br> <input class="form-check-input" type="checkbox" id="parking-page" name="parking-page" value="parking-page">
<input type="checkbox" id="default-page" name="default-page" value="default-page"> <label class="form-check-label" for="parking-page">parking-page</label><br>
<label for="default-page">default-page</label><br> </div>
<input type="checkbox" id="institution" name="institution" value="institution"> <div class="form-check">
<label for="institution">institution / company</label><br> <input class="form-check-input" type="checkbox" id="default-page" name="default-page" value="default-page">
<label class="form-check-label" for="default-page">default-page</label><br>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="institution" name="institution" value="institution">
<label class="form-check-label" for="institution">institution / company</label><br>
</div>
<!-- the name of the institution/company could be added here in the future, maybe with propositions <!-- the name of the institution/company could be added here in the future, maybe with propositions
<label for="institution-name">Enter the name of the institution/company:</label><br> <label for="institution-name">Enter the name of the institution/company:</label><br>
<input type="text" id="institution-name" name="institution-name"> <input type="text" id="institution-name" name="institution-name">
--> -->
</fieldset> </fieldset>
<fieldset id="malicious-categories"> <fieldset id="malicious-categories" hidden>
<p>Only if malicious:</p> <p>Only if malicious:</p>
<input type="checkbox" id="clone" name="clone" value="clone"> <div class="form-check">
<label for="clone">clone</label><br> <input class="form-check-input" type="checkbox" id="clone" name="clone" value="clone">
<input type="checkbox" id="phishing" name="phishing" value="phishing"> <label class="form-check-label" for="clone">clone</label><br>
<label for="phishing">phishing</label><br> </div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="phishing" name="phishing" value="phishing">
<label class="form-check-label" for="phishing">phishing</label><br>
</div>
</fieldset> </fieldset>
<input type="checkbox" id="captcha" name="captcha" value="captcha"> <div class="form-check">
<label for="captcha">captcha</label><br> <input class="form-check-input" type="checkbox" id="captcha" name="captcha" value="captcha">
<input type="checkbox" id="authentication-form" name="authentication-form" value="authentication-form"> <label class="form-check-label" for="captcha">captcha</label><br>
<label for="authentication-form">authentication-form</label><br> </div>
<input type="checkbox" id="adult-content" name="adult-content" value="adult-content"> <div class="form-check">
<label for="adult-content">adult-content</label><br> <input class="form-check-input" type="checkbox" id="authentication-form" name="authentication-form" value="authentication-form">
<input type="checkbox" id="shop" name="shop" value="shop"> <label class="form-check-label" for="authentication-form">authentication-form</label><br>
<label for="shop">shop</label><br> </div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="adult-content" name="adult-content" value="adult-content">
<label class="form-check-label" for="adult-content">adult-content</label><br>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="shop" name="shop" value="shop">
<label class="form-check-label" for="shop">shop</label><br>
</div>
</div> </div>
<label for="query" class="form-label">Category to search</label> <label for="query" class="form-label">Category to search</label>