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.