mirror of
https://github.com/moepman/bk-dss
synced 2024-12-22 23:04:26 +01:00
First edit implementation (doesn't do too much).
This commit is contained in:
parent
b75552b0b3
commit
6705ce83cc
23
index.py
23
index.py
@ -16,6 +16,16 @@ app.jinja_env.lstrip_blocks = True
|
|||||||
rdb = Redis(host=app.config.get('REDIS_HOST', '127.0.0.1'), password=app.config.get('REDIS_PSWD'))
|
rdb = Redis(host=app.config.get('REDIS_HOST', '127.0.0.1'), password=app.config.get('REDIS_PSWD'))
|
||||||
|
|
||||||
|
|
||||||
|
class ReadonlyStringField(StringField):
|
||||||
|
def __call__(self, *args, **kwargs):
|
||||||
|
kwargs.setdefault('readonly', True)
|
||||||
|
return super(ReadonlyStringField, self).__call__(*args, **kwargs)
|
||||||
|
|
||||||
|
class EditForm(Form):
|
||||||
|
user = ReadonlyStringField('Username')
|
||||||
|
pswd = PasswordField('Password')
|
||||||
|
submit = SubmitField('Submit')
|
||||||
|
|
||||||
class LoginForm(Form):
|
class LoginForm(Form):
|
||||||
user = StringField('Username', validators=[Required()])
|
user = StringField('Username', validators=[Required()])
|
||||||
pswd = PasswordField('Password', validators=[Required()])
|
pswd = PasswordField('Password', validators=[Required()])
|
||||||
@ -26,13 +36,24 @@ class LoginForm(Form):
|
|||||||
def index():
|
def index():
|
||||||
nav = None
|
nav = None
|
||||||
if 'uuid' in session:
|
if 'uuid' in session:
|
||||||
nav = ['logout']
|
nav = ['edit', 'logout']
|
||||||
else:
|
else:
|
||||||
nav = ['login']
|
nav = ['login']
|
||||||
|
|
||||||
return render_template('index.html', nav=nav)
|
return render_template('index.html', nav=nav)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/edit', methods=['GET', 'POST'])
|
||||||
|
def edit():
|
||||||
|
if 'uuid' not in session:
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
nav = ['edit', 'logout']
|
||||||
|
form = EditForm()
|
||||||
|
user = rdb.hgetall(session['uuid'])['user']
|
||||||
|
form.user.data = user
|
||||||
|
return render_template('edit.html', form=form, nav=nav)
|
||||||
|
|
||||||
@app.route('/login', methods=['GET', 'POST'])
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
def login():
|
def login():
|
||||||
nav = ['login']
|
nav = ['login']
|
||||||
|
10
templates/edit.html
Normal file
10
templates/edit.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{% from "_helpers.html" import render_field %}
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<form method="POST">
|
||||||
|
{{ form.hidden_tag() }}
|
||||||
|
{{ render_field(form.user) }}
|
||||||
|
{{ render_field(form.pswd) }}
|
||||||
|
<div class="form-group">{{ form.submit(class_="btn btn-default") }}</div>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user