From e5408a227aa0e90a7ed63879c1a12c720fd40239 Mon Sep 17 00:00:00 2001
From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de>
Date: Fri, 14 Apr 2017 01:23:46 +0200
Subject: [PATCH] Show decision categories in the tex protocol

/close #92
---
 parser.py              | 5 +++++
 tasks.py               | 4 ++++
 templates/protocol.tex | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/parser.py b/parser.py
index 9da40c7..0e9bda4 100644
--- a/parser.py
+++ b/parser.py
@@ -213,6 +213,11 @@ class Tag:
                 if not show_private:
                     return ""
                 return self.todo.render_latex(current_protocol=protocol)
+            elif self.name == "beschluss":
+                result = r"\textbf{{Beschluss:}} {}".format(self.decision.content)
+                if self.decision.category is not None:
+                    result = r"{} \textit{{({})}}".format(result, self.decision.category.name)
+                return result
             return r"\textbf{{{}:}} {}".format(escape_tex(self.name.capitalize()), escape_tex(";".join(self.values)))
         elif render_type == RenderType.plaintext:
             if self.name == "url":
diff --git a/tasks.py b/tasks.py
index 3a4dce3..fd2323f 100644
--- a/tasks.py
+++ b/tasks.py
@@ -285,6 +285,7 @@ def parse_protocol_async_inner(protocol, encoded_kwargs):
         protocol.decisions.remove(decision)
     db.session.commit()
     decision_tags = [tag for tag in tags if tag.name == "beschluss"]
+    decisions_to_render = []
     for decision_tag in decision_tags:
         if len(decision_tag.values) == 0:
             error = protocol.create_error("Parsing", "Empty decision found.",
@@ -320,6 +321,9 @@ def parse_protocol_async_inner(protocol, encoded_kwargs):
             content=decision_content, category_id=decision_category_id)
         db.session.add(decision)
         db.session.commit()
+        decision_tag.decision = decision
+        decisions_to_render.append((decision, decision_tag))
+    for decision, decision_tag in decisions_to_render:
         decision_top = decision_tag.fork.get_top()
         decision_content = texenv.get_template("decision.tex").render(
             render_type=RenderType.latex, decision=decision,
diff --git a/templates/protocol.tex b/templates/protocol.tex
index 1c757ba..41a759e 100644
--- a/templates/protocol.tex
+++ b/templates/protocol.tex
@@ -38,7 +38,7 @@
 \begin{itemize}
 \ENV{if protocol.decisions|length > 0}
     \ENV{for decision in protocol.decisions}
-        \item \VAR{decision.content|escape_tex}
+        \item \VAR{decision.content|escape_tex}\ENV{if decision.category is not none and show_private} \textit{(\VAR{decision.category.name})}\ENV{endif}
     \ENV{endfor}
 \ENV{else}
 	\item Keine Beschlüsse
-- 
GitLab