Skip to content
Snippets Groups Projects
Commit 17b8461f authored by Administrator's avatar Administrator
Browse files

Added debug output for reminder mails

parent baeab64f
No related branches found
No related tags found
No related merge requests found
...@@ -538,6 +538,13 @@ class Todo(db.Model): ...@@ -538,6 +538,13 @@ class Todo(db.Model):
] ]
return " ".join(parts) 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): def render_latex(self, current_protocol=None):
return r"\textbf{{{}}}: {}: {} -- {}".format( return r"\textbf{{{}}}: {}: {} -- {}".format(
"Neuer Todo" if self.is_new(current_protocol) else "Todo", "Neuer Todo" if self.is_new(current_protocol) else "Todo",
......
...@@ -1228,13 +1228,17 @@ def check_and_send_reminders(): ...@@ -1228,13 +1228,17 @@ def check_and_send_reminders():
with app.app_context(): with app.app_context():
current_time = datetime.now() current_time = datetime.now()
current_day = current_time.date() current_day = current_time.date()
print("regular action for reminders")
for protocol in Protocol.query.filter(Protocol.done == False).all(): for protocol in Protocol.query.filter(Protocol.done == False).all():
day_difference = (protocol.date - current_day).days day_difference = (protocol.date - current_day).days
usual_time = protocol.protocoltype.usual_time usual_time = protocol.protocoltype.usual_time
protocol_time = datetime(1, 1, 1, usual_time.hour, usual_time.minute) protocol_time = datetime(1, 1, 1, usual_time.hour, usual_time.minute)
hour_difference = (protocol_time - current_time).seconds // 3600 hour_difference = (protocol_time - current_time).seconds // 3600
print("diff: {} days, {} hours".format(day_difference, hour_difference))
for reminder in protocol.protocoltype.reminders: for reminder in protocol.protocoltype.reminders:
print(reminder)
if day_difference == reminder.days_before and hour_difference == 0: if day_difference == reminder.days_before and hour_difference == 0:
print("reminder matching, sending")
tasks.send_reminder(reminder, protocol) tasks.send_reminder(reminder, protocol)
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -445,8 +445,10 @@ def send_reminder_async(reminder_id, protocol_id): ...@@ -445,8 +445,10 @@ def send_reminder_async(reminder_id, protocol_id):
protocol = Protocol.query.filter_by(id=protocol_id).first() protocol = Protocol.query.filter_by(id=protocol_id).first()
reminder_text = render_template("reminder-mail.txt", reminder=reminder, protocol=protocol) reminder_text = render_template("reminder-mail.txt", reminder=reminder, protocol=protocol)
if reminder.send_public: 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) send_mail(protocol, protocol.protocoltype.public_mail, "Tagesordnung der {}".format(protocol.protocoltype.name), reminder_text)
if reminder.send_private: 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) send_mail(protocol, protocol.protocoltype.private_mail, "Tagesordnung der {}".format(protocol.protocoltype.name), reminder_text)
def send_protocol(protocol): def send_protocol(protocol):
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<ul> <ul>
{% if todos|length > 0 %} {% if todos|length > 0 %}
{% for todo in todos %} {% for todo in todos %}
<li>{{todo.render_html()|safe}}</li> <li>{{todo.render_html_short()|safe}}</li>
{% endfor %} {% endfor %}
{% else %} {% else %}
<li>Keine Todos</li> <li>Keine Todos</li>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment