From 08a4ffa89f2b144c8c12a46fd61f1083fd9977a5 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 25 Sep 2023 13:05:12 +0100 Subject: [PATCH] Web UI to edit conference title Resolves: #3 --- main.py | 20 +++++++++++++++++--- templates/conference.html | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index de9dacb..c85ec45 100755 --- a/main.py +++ b/main.py @@ -125,13 +125,27 @@ def event_page(event_id: int) -> str: return flask.render_template("event.html", item=item) -@app.route("/conference/") -def conference_page(short_name: str) -> str: +@app.route("/conference/", methods=["GET", "POST"]) +def conference_page(short_name: str) -> str | Response: item = model.Conference.query.filter_by(short_name=short_name).one_or_none() if item is None: flask.abort(404) + + if flask.request.method == "POST" and check_admin_mode(): + item.short_name = flask.request.form["short_name"] + item.title = flask.request.form["title"] + database.session.commit() + + assert flask.request.endpoint + return flask.redirect( + flask.url_for(flask.request.endpoint, short_name=item.short_name) + ) + return flask.render_template( - "conference.html", item=item, person_image_filename=person_image_filename + "conference.html", + item=item, + person_image_filename=person_image_filename, + is_admin=check_admin_mode, ) diff --git a/templates/conference.html b/templates/conference.html index 56fc448..3c58ea6 100644 --- a/templates/conference.html +++ b/templates/conference.html @@ -86,6 +86,21 @@ + {% if is_admin() %} +
+
+ + +
+
+ + +
+ + +
+ {% endif %} +

Talks

{{ item.events.count() }} talks