From e6647a642551121b0cfc6ce235e564589318d533 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 24 Sep 2023 09:21:16 +0100 Subject: [PATCH] Admin mode needed for some features --- main.py | 4 ++++ templates/navbar.html | 4 +++- templates/person.html | 7 ++++--- templates/search_people.html | 5 ++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index b099df6..35fe72b 100755 --- a/main.py +++ b/main.py @@ -182,6 +182,8 @@ def search_people() -> str: @app.route("/merge", methods=["GET", "POST"]) def merge() -> str | Response: + assert app.config["ADMIN_MODE"] + if flask.request.method == "POST": search_for = flask.request.form["q"] @@ -407,6 +409,8 @@ def search_everything() -> str: @app.route("/person//delete", methods=["POST"]) def delete_person(person_id: int) -> str | Response: + assert app.config["ADMIN_MODE"] + item = model.Person.query.get(person_id) for cp in item.conferences_association: diff --git a/templates/navbar.html b/templates/navbar.html index c858ae0..eca8885 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -1,7 +1,9 @@

- home + conferences + {# | events + #} | speakers diff --git a/templates/person.html b/templates/person.html index 191eaad..d37ddde 100644 --- a/templates/person.html +++ b/templates/person.html @@ -21,8 +21,8 @@ {% block content %} -
-
+
+
{% set photo = item.photo_filename() %} {% if photo %} @@ -45,7 +45,7 @@ {% endif %}

- + {% if config.ADMIN_MODE %} {% set search_for = item.name + ' ' + " haswbstatement:P31=Q5" %}

Search for {{ item.name }} on Wikidata

@@ -80,6 +80,7 @@

No similar names found on Wikidata

{% endif %} {% endif %} + {% endif %} {% set bio_source = item.bio_source() %} {% if bio_source %} diff --git a/templates/search_people.html b/templates/search_people.html index bb1572b..aabe7fe 100644 --- a/templates/search_people.html +++ b/templates/search_people.html @@ -17,9 +17,12 @@

- Found {{ q.count() }} people matching '{{ search_for }}' + {% set count = q.count() %} + Found {{ count }} people matching '{{ search_for }}' + {% if config.ADMIN_MODE and count %} merge + {% endif %}