From 4dff3185d9deccf9451d8fc30c35c5628805a5d7 Mon Sep 17 00:00:00 2001
From: Markus Scheller <scheller_m@live.de>
Date: Sat, 24 Feb 2018 20:33:38 +0100
Subject: [PATCH] Add configuration SelectField for latex_template selection

protokollsystem/proto3#170
---
 views/forms.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/views/forms.py b/views/forms.py
index 67b39af..0512117 100644
--- a/views/forms.py
+++ b/views/forms.py
@@ -58,6 +58,17 @@ def get_printer_choices():
         choices = list(zip(config.PRINTING_PRINTERS, config.PRINTING_PRINTERS))
     choices.insert(0, ("", "Nicht drucken"))
     return choices
+	
+def get_latex_template_choices():
+    choices = []
+    if config.LATEX_TEMPLATES is not None:
+        choices = [
+            (key, values['name'])
+            for key, values
+            in config.LATEX_TEMPLATES.items()
+        ]
+    choices.insert(0, ("", "Standardvorlage"))
+    return choices
 
 def get_group_choices():
     user = current_user()
@@ -130,12 +141,14 @@ class ProtocolTypeForm(FlaskForm):
     calendar = SelectField("Kalender", choices=[])
     restrict_networks = BooleanField("Netzwerke einschränken")
     allowed_networks = IPNetworkField("Erlaubte Netzwerke")
+    latex_template = SelectField("LaTeX Vorlage", choices=[])
 
     def __init__(self, **kwargs):
         super().__init__(**kwargs)
         protocoltype = kwargs["obj"] if "obj" in kwargs else None
         self.calendar.choices = get_calendar_choices(protocoltype=protocoltype)
         self.printer.choices = get_printer_choices()
+        self.latex_template.choices = get_latex_template_choices()
         group_choices = get_group_choices()
         self.publish_group.choices = group_choices
         self.modify_group.choices = group_choices
-- 
GitLab