diff --git a/models/database.py b/models/database.py index ef496f5a0a2cf0022027d43cbe9231dbe029b8bc..e3b3c5a3b9ffcfee7d28f5a97ca0c6a29a3deeb5 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 ebc58a3291dce7694e36c51a6bd5a78e345c7bda..1a96a60e9892d2f7d48514028925c96ddd4bfee1 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 903e34b1431f5f34d60777f49b45fbef1c12ecef..6d4395b2dbea7ea929894737d11193917987e02d 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 f18560586a2f12d77de75b3a91ac86a2200157aa..89d6c1e8b6594741d5c9ea0ff62deb98c4a71738 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>