Commit 17b8461f authored by Administrator's avatar Administrator
Browse files

Added debug output for reminder mails

parent baeab64f
......@@ -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",
......
......@@ -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__":
......
......@@ -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):
......
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment