Admin mode needed for some features

This commit is contained in:
Edward Betts 2023-09-24 09:21:16 +01:00
parent 2cf5dbb22e
commit e6647a6425
4 changed files with 15 additions and 5 deletions

View file

@ -182,6 +182,8 @@ def search_people() -> str:
@app.route("/merge", methods=["GET", "POST"]) @app.route("/merge", methods=["GET", "POST"])
def merge() -> str | Response: def merge() -> str | Response:
assert app.config["ADMIN_MODE"]
if flask.request.method == "POST": if flask.request.method == "POST":
search_for = flask.request.form["q"] search_for = flask.request.form["q"]
@ -407,6 +409,8 @@ def search_everything() -> str:
@app.route("/person/<int:person_id>/delete", methods=["POST"]) @app.route("/person/<int:person_id>/delete", methods=["POST"])
def delete_person(person_id: int) -> str | Response: def delete_person(person_id: int) -> str | Response:
assert app.config["ADMIN_MODE"]
item = model.Person.query.get(person_id) item = model.Person.query.get(person_id)
for cp in item.conferences_association: for cp in item.conferences_association:

View file

@ -1,7 +1,9 @@
<p> <p>
<form action="{{ url_for("search_people") }}"> <form action="{{ url_for("search_people") }}">
<a href="{{ url_for("index") }}">home</a> <a href="{{ url_for("index") }}">conferences</a>
{#
| <a href="{{ url_for("events_page") }}">events</a> | <a href="{{ url_for("events_page") }}">events</a>
#}
| <a href="{{ url_for("top_speakers_page") }}">speakers</a> | <a href="{{ url_for("top_speakers_page") }}">speakers</a>
<input type="text" class="form-control" placeholder="speaker name" name="q" id="q"> <input type="text" class="form-control" placeholder="speaker name" name="q" id="q">

View file

@ -21,8 +21,8 @@
{% block content %} {% block content %}
<div class="container"> <div>
<div class="row"> <div>
{% set photo = item.photo_filename() %} {% set photo = item.photo_filename() %}
{% if photo %} {% if photo %}
@ -45,7 +45,7 @@
{% endif %} {% endif %}
</p> </p>
{% if config.ADMIN_MODE %}
{% set search_for = item.name + ' ' + " haswbstatement:P31=Q5" %} {% set search_for = item.name + ' ' + " haswbstatement:P31=Q5" %}
<p><a href="https://www.wikidata.org/w/index.php?search={{ search_for | urlencode }}&title=Special%3ASearch&ns0=1&ns120=1">Search for {{ item.name }} on Wikidata</a></p> <p><a href="https://www.wikidata.org/w/index.php?search={{ search_for | urlencode }}&title=Special%3ASearch&ns0=1&ns120=1">Search for {{ item.name }} on Wikidata</a></p>
@ -80,6 +80,7 @@
<p>No similar names found on Wikidata</p> <p>No similar names found on Wikidata</p>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %}
{% set bio_source = item.bio_source() %} {% set bio_source = item.bio_source() %}
{% if bio_source %} {% if bio_source %}

View file

@ -17,9 +17,12 @@
</form> </form>
<p> <p>
Found {{ q.count() }} people matching '{{ search_for }}' {% set count = q.count() %}
Found {{ count }} people matching '{{ search_for }}'
{% if config.ADMIN_MODE and count %}
<a href="{{ url_for("merge", q=search_for) }}">merge</a> <a href="{{ url_for("merge", q=search_for) }}">merge</a>
{% endif %}
</p> </p>
<ul> <ul>