Commit 9cd4cfc1 authored by Hinrikus Wolf's avatar Hinrikus Wolf

complete support for naming speaker

parent 67562611
......@@ -26,11 +26,10 @@ class AddStatementForm(Form):
speaker_name = StringField("Speaker", validators=[InputRequired("Entering the speaker is required.")])
topic = HiddenField("Topic")
class AddNameToSpeaker(Form):
speaker_name = StringField("Speaker", validators=[InputRequired("Entering the speaker is required.")])
number = HiddenField("Speaker_id", validators=[NumberRange(min=0, message=None),InputRequired("ID must be a positve Integer.")])
class EditSpeakerForm(Form):
name = StringField("Speaker", validators=[InputRequired("Entering the speaker is required.")])
topic_id = HiddenField("Topic_id")
event_id = HiddenField("Event_id")
id = HiddenField("Speaker_id")
class NewEventForm(Form):
name = StringField("Name", validators=[InputRequired("Entering the name is required.")])
......
......@@ -3,7 +3,7 @@ from flask.ext.login import login_required
from passlib.hash import pbkdf2_sha256
from models.database import User, Topic, Event, Speaker, Statement
from models.forms import AdminUserForm, NewUserForm, NewTopicForm, NewEventForm, AddStatementForm
from models.forms import AdminUserForm, NewUserForm, NewTopicForm, NewEventForm, AddStatementForm, EditSpeakerForm
from shared import db, admin_permission
from utils import render_layout, speaker_by_name_or_number
......@@ -206,25 +206,26 @@ def topic():
@admin.route("/speaker/rename", methods=["GET", "POST"])
@login_required
@admin_permission.require()
def rename():
def speaker_edit():
#speaker = Speaker.query.filter_by(number=number,event).first()
#if speaker is not None:
form = AddNameToSpeaker(obj=speaker)
speaker = Speaker.query.filter_by(number=form.number.data, event_id=form.event_id.data).first()
#id=statement.speaker.identifier(), topic_id=topic.id)
speaker_id = request.args.get("id", None)
topic_id = request.args.get("topic_id", None)
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.speaker_name.data
speaker.name = form.name.data
db.session.commit()
return redirect(url_for(".topic_show",id=form.topic_id.data))
else:
return render_layout("admin_speaker_edit.html", form=form, speaker=speaker, topic_id=topic_id)
else:
return redirect(url_for(".index"))
@admin.route("/statement/")
......
{% extends "layout.html" %}
{% from "macros.html" import render_form %}
{% block title %}Edit Speaker - Administration{% endblock %}
{% block content %}
{{ render_form(form, action_url=url_for(".speaker_edit", id=speaker.id,topic_id=form.topic_id.data), action_text="Apply", title="Edit Speaker") }}
{% endblock %}
......@@ -11,6 +11,7 @@
<th class="mdl-data-table__cell--non-numeric">Topic</th>
<th class="mdl-data-table__cell--non-numeric">Count</th>
<th class="mdl-data-table__cell--non-numeric">Done</th>
<th class="mdl-data-table__cell--non-numeric">Edit</th>
<th class="mdl-data-table__cell--non-numeric">Remove</th>
</tr>
</thead>
......@@ -25,6 +26,12 @@
<i class="material-icons">done</i>
</a>
</td>
<td class="mdl-data-table__cell--non-numeric">
<a href="{{ url_for(".speaker_edit", id=statement.speaker.id, topic_id=topic.id) }}">
<i class="material-icons">edit</i>
</a>
</td>
<td class="mdl-data-table__cell--non-numeric">
<a href="{{ url_for('.statement_delete', id=statement.id, topic_id=topic.id) }}">
<i class="material-icons">cancel</i>
......
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