From 3581f84da5392e4b3bafc7fe4d837ba5bf8d3392 Mon Sep 17 00:00:00 2001
From: Hinrikus Wolf <hinrikus.wolf@rwth-aachen.de>
Date: Sat, 7 Nov 2015 23:21:11 +0100
Subject: [PATCH] add support for meta-button, still useless

---
 modules/admin.py                   | 20 +++++++++++++-------
 templates/admin_statement_new.html |  2 +-
 templates/admin_topic_show.html    |  2 +-
 templates/macros.html              |  4 ++--
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/modules/admin.py b/modules/admin.py
index a18f4e7..d26ddf0 100644
--- a/modules/admin.py
+++ b/modules/admin.py
@@ -274,14 +274,20 @@ def statement():
 def statement_new():
     form = AddStatementForm()
     if form.validate_on_submit():
-        topic = Topic.query.filter_by(id=form.topic.data).first()
-        speaker = speaker_by_name_or_number(form.speaker_name.data, topic.event.id)
-        if topic is not None and speaker is not None:
-            if speaker.count_active(topic) == 0:
-                statement = Statement(speaker.id, topic.id)
-                db.session.add(statement)
-                db.session.commit()
+        statement = request.form.get("submit","add_statement")
+        if statement == "add_meta_statement":
+            topic = Topic.query.filter_by(id=form.topic.data).first()
+            
             return redirect(url_for(".topic_show", id=topic.id))
+        else:
+            topic = Topic.query.filter_by(id=form.topic.data).first()
+            speaker = speaker_by_name_or_number(form.speaker_name.data, topic.event.id)
+            if topic is not None and speaker is not None:
+                if speaker.count_active(topic) == 0:
+                    statement = Statement(speaker.id, topic.id)
+                    db.session.add(statement)
+                    db.session.commit()
+                return redirect(url_for(".topic_show", id=topic.id))
     return render_layout("admin_statement_new.html", form=form)
 
 @admin.route("/statement/done")
diff --git a/templates/admin_statement_new.html b/templates/admin_statement_new.html
index 8550596..ec6d833 100644
--- a/templates/admin_statement_new.html
+++ b/templates/admin_statement_new.html
@@ -3,5 +3,5 @@
 {% block admin_title %}Add Statement{% endblock %}
 
 {% block content %}
-        {{ render_form(form, action_url=url_for(".statement_new"), btn_list=[("","Add Statement","add_statement"),  ("redl-btn-meta","Add Meta","add_meta_statement")]) }}
+        {{ render_form(form, action_url=url_for(".statement_new"), btn_list=[("","Add Statement","add_statement"),  ("mdl-button--colored","Add Meta","add_meta_statement")]) }}
 {% endblock %}
diff --git a/templates/admin_topic_show.html b/templates/admin_topic_show.html
index cc6c429..8c9e4fd 100644
--- a/templates/admin_topic_show.html
+++ b/templates/admin_topic_show.html
@@ -47,7 +47,7 @@
     </div>
     <div class="mdl-separator rede-separator"></div>
     <div class="mdl-cell mdl-cell--3-col mdl-cell--3-col-tablet mdl-cell--4-col-phone mdl-grid mdl-grid--no-spacing">
-        {{ render_form(form, action_url=url_for(".statement_new"), action_text="Add", title="Add Statement", class_="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone", btn_list=[("","Add Statement","add_statement"),  ("redl-btn-meta","Add Meta","add_meta_statement")] ) }}
+        {{ render_form(form, action_url=url_for(".statement_new"), action_text="Add", title="Add Statement", class_="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone", btn_list=[("","Add Statement","add_statement"),  ("mdl-button--colored","Add Meta","add_meta_statement")] ) }}
         <div class="mdl-cell mdl-card mdl-shadow--2dp mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
             <ul class="rede-list-no-bullet">
                 {% if topic.sorted_statements()|length() > 0 %}
diff --git a/templates/macros.html b/templates/macros.html
index 655263b..4a2ac7e 100644
--- a/templates/macros.html
+++ b/templates/macros.html
@@ -135,10 +135,10 @@
             <div class="{{ action_class }}">
                 {% if btn_list != none %}
                     {%for this_btn_class, action_text, btn_value in btn_list %}
-	                <button type="submit" class="{{ btn_class }} {{ this_btn_class }}", value="{{ btn_value }}">{{ action_text }}</button>
+	                <button type="submit" class="{{ btn_class }} {{ this_btn_class }}" name="submit" value="{{ btn_value }}">{{ action_text }}</button>
                     {% endfor %}
 		{% else %}
-                <button type="submit" class="{{ btn_class }}", value="{{ btn_value }}">{{ action_text }}</button>
+                <button type="submit" class="{{ btn_class }}" value="{{ btn_value }}">{{ action_text }}</button>
                 {% endif %}
                 
             </div>
-- 
GitLab