Improve admin settings page
The improvements are mostly cosmetic^Wquestionable.
This commit is contained in:
parent
dd607dbddd
commit
8c824fe9e6
|
@ -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:
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
Tu lahko urejate splošne nastavitve.
|
||||
|
||||
<form id="request" method="POST">
|
||||
<h2>Nastavitve</h2>
|
||||
<table>
|
||||
<tbody>
|
||||
{% for name, value in settings.items() %}
|
||||
<p>
|
||||
<input type="hidden" name="setting" value="{{ name }}" />
|
||||
<label>{{ name }}<br><input name="value" value="{{ value }}" /></label>
|
||||
<tr>
|
||||
<td><label for="{{ name }}">{{ name }}</label>
|
||||
<td><input id="{{ name }}" name="{{ name }}" value="{{ value }}" size="40" />
|
||||
{% endfor %}
|
||||
</table>
|
||||
<p><button id="submit" type="submit">Shrani</button>
|
||||
</form>
|
||||
|
||||
|
|
Loading…
Reference in a new issue