From 8266217c269636f8403d6f2911727ae20e228fa3 Mon Sep 17 00:00:00 2001
From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de>
Date: Sat, 17 Feb 2018 12:54:48 +0100
Subject: [PATCH] Add reference to the next protocol in mail

/close #162
---
 tasks.py                    | 3 ++-
 templates/protocol-mail.txt | 8 +++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tasks.py b/tasks.py
index 69aea9b..6dc8366 100644
--- a/tasks.py
+++ b/tasks.py
@@ -688,9 +688,10 @@ def send_protocol_public(protocol):
 def send_protocol_async(protocol_id, show_private):
     with app.app_context():
         protocol = Protocol.query.filter_by(id=protocol_id).first()
+        next_protocol = Protocol.query.filter_by(protocoltype_id=protocol.protocoltype.id).filter_by(done=False).filter(Protocol.date > datetime.now()).order_by(Protocol.date).first()
         to_addr = protocol.protocoltype.private_mail if show_private else protocol.protocoltype.public_mail
         subject = "{}{}-Protokoll vom {}".format("Internes " if show_private else "", protocol.protocoltype.short_name, date_filter(protocol.date))
-        mail_content = render_template("protocol-mail.txt", protocol=protocol, show_private=show_private)
+        mail_content = render_template("protocol-mail.txt", protocol=protocol, show_private=show_private, next_protocol=next_protocol)
         appendix = [(document.name, document.as_file_like())
             for document in protocol.documents
             if show_private or not document.is_private
diff --git a/templates/protocol-mail.txt b/templates/protocol-mail.txt
index 0cb09c8..527fb26 100644
--- a/templates/protocol-mail.txt
+++ b/templates/protocol-mail.txt
@@ -10,7 +10,7 @@ Zeit: von {{protocol.start_time|timify}} bis {{protocol.end_time|timify}}
 {% endif %}
 {% endfor %}
 
-Die Tagesordnung ist:
+Die Tagesordnung war:
 {% for top in protocol.get_tops() %}
 * {{top.name}}
 {% endfor %}
@@ -23,3 +23,9 @@ Beschlüsse:
 {% else %}
 * Keine Beschlüsse
 {% endif %}
+
+{% if next_protocol is not none %}
+Die nächste Sitzung findet am {{next_protocol.date|datify}} statt.
+{% else %}
+Es wurde noch keine nächste Sitzung angelegt!
+{% endif %}
-- 
GitLab