From 323a89a1225cfc16871e1befaf9c0489687fd462 Mon Sep 17 00:00:00 2001
From: Hinrikus Wolf <hinrikus.wolf@rwth-aachen.de>
Date: Sat, 7 Nov 2015 22:04:22 +0100
Subject: [PATCH] add support for more than one button per form

---
 templates/admin_statement_new.html |  2 +-
 templates/admin_topic_show.html    |  2 +-
 templates/macros.html              | 12 ++++++++++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/templates/admin_statement_new.html b/templates/admin_statement_new.html
index 5510387..8550596 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"), action_text="Add", title="Add Statement") }}
+        {{ render_form(form, action_url=url_for(".statement_new"), btn_list=[("","Add Statement","add_statement"),  ("redl-btn-meta","Add Meta","add_meta_statement")]) }}
 {% endblock %}
diff --git a/templates/admin_topic_show.html b/templates/admin_topic_show.html
index 566ad10..03e453f 100644
--- a/templates/admin_topic_show.html
+++ b/templates/admin_topic_show.html
@@ -44,7 +44,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") }}
+        {{ 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")] ) }}
         <div class="mdl-cell mdl-card mdl-shadow--2dp mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
             <ul>
                 {% if topic.sorted_statements()|length() > 0 %}
diff --git a/templates/macros.html b/templates/macros.html
index 3150025..655263b 100644
--- a/templates/macros.html
+++ b/templates/macros.html
@@ -104,7 +104,7 @@
 {%- endmacro %}
 
 
-{% macro render_form(form, action_url="", title=None, action_text="Submit", class_="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--4-col-phone", title_class="mdl-card__title", title_text_class="mdl-card__title-text", content_class="mdl-card__supporting-text", action_class="mdl-card__actions", btn_class="mdl-button mdl-js-button mdl-button--raised mdl-button-colored") -%}
+{% macro render_form(form, action_url="", title=None, action_text="Submit", class_="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--4-col-phone", title_class="mdl-card__title", title_text_class="mdl-card__title-text", content_class="mdl-card__supporting-text", action_class="mdl-card__actions", btn_class="mdl-button mdl-js-button mdl-button--raised mdl-button-colored", btn_value="", btn_list=None) -%}
     <div class="{{ class_ }}">
         <form method="POST" action="{{ action_url }}">
             <div class="{{ title_class }}">
@@ -133,8 +133,16 @@
                 {% endfor %}
             </div>
             <div class="{{ action_class }}">
-                <button type="submit" class="{{ btn_class }}">{{ action_text }}</button>
+                {% 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>
+                    {% endfor %}
+		{% else %}
+                <button type="submit" class="{{ btn_class }}", value="{{ btn_value }}">{{ action_text }}</button>
+                {% endif %}
+                
             </div>
         </form>
     </div>
 {%- endmacro %}
+
-- 
GitLab