From 17b8461f29e4d1a47f7cfadaa6afaa98e8a20b2b Mon Sep 17 00:00:00 2001 From: FSMPI Admin-Team <admin@fsmpi.rwth-aachen.de> Date: Fri, 3 Mar 2017 22:53:11 +0100 Subject: [PATCH] Added debug output for reminder mails --- models/database.py | 7 +++++++ server.py | 4 ++++ tasks.py | 2 ++ templates/index.html | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/models/database.py b/models/database.py index ef496f5..e3b3c5a 100644 --- a/models/database.py +++ b/models/database.py @@ -538,6 +538,13 @@ class Todo(db.Model): ] return " ".join(parts) + def render_html_short(self): + parts = [ + "<strong>{}:</strong>".format(self.who), + self.description + ] + return " ".join(parts) + def render_latex(self, current_protocol=None): return r"\textbf{{{}}}: {}: {} -- {}".format( "Neuer Todo" if self.is_new(current_protocol) else "Todo", diff --git a/server.py b/server.py index ebc58a3..1a96a60 100755 --- a/server.py +++ b/server.py @@ -1228,13 +1228,17 @@ def check_and_send_reminders(): with app.app_context(): current_time = datetime.now() current_day = current_time.date() + print("regular action for reminders") for protocol in Protocol.query.filter(Protocol.done == False).all(): day_difference = (protocol.date - current_day).days usual_time = protocol.protocoltype.usual_time protocol_time = datetime(1, 1, 1, usual_time.hour, usual_time.minute) hour_difference = (protocol_time - current_time).seconds // 3600 + print("diff: {} days, {} hours".format(day_difference, hour_difference)) for reminder in protocol.protocoltype.reminders: + print(reminder) if day_difference == reminder.days_before and hour_difference == 0: + print("reminder matching, sending") tasks.send_reminder(reminder, protocol) if __name__ == "__main__": diff --git a/tasks.py b/tasks.py index 903e34b..6d4395b 100644 --- a/tasks.py +++ b/tasks.py @@ -445,8 +445,10 @@ def send_reminder_async(reminder_id, protocol_id): protocol = Protocol.query.filter_by(id=protocol_id).first() reminder_text = render_template("reminder-mail.txt", reminder=reminder, protocol=protocol) if reminder.send_public: + print("sending public reminder mail to {}".format(protocol.protocoltype.public_mail)) send_mail(protocol, protocol.protocoltype.public_mail, "Tagesordnung der {}".format(protocol.protocoltype.name), reminder_text) if reminder.send_private: + print("sending private reminder mail to {}".format(protocol.protocoltype.private_mail)) send_mail(protocol, protocol.protocoltype.private_mail, "Tagesordnung der {}".format(protocol.protocoltype.name), reminder_text) def send_protocol(protocol): diff --git a/templates/index.html b/templates/index.html index f185605..89d6c1e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -26,7 +26,7 @@ <ul> {% if todos|length > 0 %} {% for todo in todos %} - <li>{{todo.render_html()|safe}}</li> + <li>{{todo.render_html_short()|safe}}</li> {% endfor %} {% else %} <li>Keine Todos</li> -- GitLab