From 8c824fe9e6c304e3619c0cf313f73344310e46ec Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 7 Jul 2023 13:23:51 +0200 Subject: [PATCH] Improve admin settings page The improvements are mostly cosmetic^Wquestionable. --- web/config.py | 13 ++++++++++--- web/templates/config/index.html | 10 ++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/web/config.py b/web/config.py index 96f20f2..6e19f9b 100644 --- a/web/config.py +++ b/web/config.py @@ -14,13 +14,20 @@ def index(): try: if not flask_login.current_user.is_admin: return flask.Response('forbidden', status=403, mimetype='text/plain') + with db.locked(): + settings = db.read('settings') + if flask.request.method == 'POST': form = flask.request.form - db.write('settings', dict(zip(form.getlist('setting'), form.getlist('value')))) + for name, value in form.items(): + if name in settings: + settings[name] = value + db.write('settings', settings) system.run(system.save_config) - settings = db.read('settings') - return flask.render_template('config/index.html', **locals()) + return flask.redirect(flask.url_for('config.index')) + + return flask.render_template('config/index.html', settings=settings) except TimeoutError: return flask.render_template('busy.html') except Exception as e: diff --git a/web/templates/config/index.html b/web/templates/config/index.html index 2df6356..360e514 100644 --- a/web/templates/config/index.html +++ b/web/templates/config/index.html @@ -5,12 +5,14 @@ Tu lahko urejate splošne nastavitve.
-

Nastavitve

+ + {% for name, value in settings.items() %} -

- - +

+
+ {% endfor %} +