Commit ac11ceeb authored by Robin Sonnabend's avatar Robin Sonnabend

Nummer zu Speaker eintragen

parent d26ebece
......@@ -23,11 +23,12 @@ class AdminUserForm(Form):
roles = SelectMultipleField("User roles", choices=[(x.lower().strip(), x) for x in shared.roles])
class AddStatementForm(Form):
speaker_name = StringField("Speaker", validators=[InputRequired("Entering the speaker is required.")])
speaker_name = StringField("Speaker", validators=[InputRequired("Entering the speaker name or number is required.")])
topic = HiddenField("Topic")
class EditSpeakerForm(Form):
name = StringField("Speaker", validators=[InputRequired("Entering the speaker is required.")])
number = IntegerField("Number", validators=[Optional(), NumberRange(min=0)])
topic_id = HiddenField("Topic_id")
id = HiddenField("Speaker_id")
......
......@@ -252,10 +252,11 @@ def speaker_edit():
speaker = Speaker.query.filter_by(id=speaker_id).first()
form = EditSpeakerForm(obj=speaker)
form.topic_id.data=topic_id
if speaker is not None:
if form.validate_on_submit():
speaker.name = form.name.data
speaker.number = form.number.data
db.session.commit()
return redirect(url_for(".topic_show",id=form.topic_id.data))
else:
......
......@@ -22,6 +22,22 @@
</div>
{%- endmacro %}
{% macro render_integerfield(field) -%}
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input id="{{ field.id }}" name="{{ field.id }}" class="mdl-textfield__input" type="text" {% if field.data is not none %}value="{{ field.data }}"{% endif %} />
<label class="mdl-textfield__label" for="{{ field.id }}">{{ field.label.text }}</label>
{% if field.errors %}
{% for e in field.errors %}
<div class="mdl-card__supporting-text">
{{ e }}
</div>
{% endfor %}
{% endif %}
</div>
{%- endmacro %}
{% macro render_passwordfield(field) -%}
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input id="{{ field.id }}" name="{{ field.id }}" class="mdl-textfield__input" type="password" />
......@@ -116,6 +132,8 @@
{{ render_stringfield(f) }}
{% elif f.type == "PasswordField" %}
{{ render_passwordfield(f) }}
{% elif f.type == "IntegerField" %}
{{ render_integerfield(f) }}
{% elif f.type == "BooleanField" %}
{{ render_booleanfield(f) }}
{% elif f.type == "CSRFTokenField" %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment