Skip to content
Snippets Groups Projects
Commit 36ff1a14 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Add option to manually send reminder mails

/close #52
parent a8607ef8
No related branches found
No related tags found
No related merge requests found
...@@ -661,6 +661,33 @@ def send_protocol(protocol): ...@@ -661,6 +661,33 @@ def send_protocol(protocol):
flash("Das Protokoll wurde versandt.", "alert-success") flash("Das Protokoll wurde versandt.", "alert-success")
return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=protocol.id)) return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=protocol.id))
@app.route("/protocol/reminder/<int:protocol_id>")
@login_required
@db_lookup(Protocol)
@require_modify_right()
def send_protocol_reminder(protocol):
if not config.MAIL_ACTIVE:
flash("Die Mailfunktion ist nicht aktiviert.", "alert-error")
return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=protocol_id))
meetingreminders = MeetingReminder.query.filter_by(protocoltype_id=protocol.protocoltype.id).all()
if len(meetingreminders) == 0:
flash("Für diesen Protokolltyp sind keine Einladungsmails konfiguriert.", "alert-error")
return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=protocol_id))
day_difference = (protocol.date - datetime.now().date()).days
past_reminders = [
meetingreminder for meetingreminder in meetingreminders
if meetingreminder.days_before > day_difference
]
if len(past_reminders) == 0:
flash("Bisher hätte keine Einladungsmail verschickt werden sollen, schicke letzte.", "alert-info")
past_reminders = meetingreminders
past_reminders = sorted(past_reminders, key=lambda r: r.days_before)
choosen_reminder = past_reminders[0]
tasks.send_reminder(choosen_reminder, protocol)
flash("Einladungsmail ist versandt.", "alert-success")
return redirect(request.args.get("next") or url_for("show_protocol", protocol_id=protocol.id))
@app.route("/protocol/tops/new/<int:protocol_id>", methods=["GET", "POST"]) @app.route("/protocol/tops/new/<int:protocol_id>", methods=["GET", "POST"])
@login_required @login_required
@db_lookup(Protocol) @db_lookup(Protocol)
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
{% endif %} {% endif %}
{% if not protocol.is_done() %} {% if not protocol.is_done() %}
<a class="btn btn-default" href="{{url_for("get_protocol_template", protocol_id=protocol.id)}}">Vorlage</a> <a class="btn btn-default" href="{{url_for("get_protocol_template", protocol_id=protocol.id)}}">Vorlage</a>
{% if config.MAIL_ACTIVE %}
<a class="btn btn-default" href="{{url_for("send_protocol_reminder", protocol_id=protocol.id)}}" onclick="return confirm('Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.');">Einladung versenden</a>
{% endif %}
{% else %} {% else %}
{% if config.MAIL_ACTIVE %} {% if config.MAIL_ACTIVE %}
<a class="btn btn-default" href="{{url_for("send_protocol", protocol_id=protocol.id)}}">Mail versenden</a> <a class="btn btn-default" href="{{url_for("send_protocol", protocol_id=protocol.id)}}">Mail versenden</a>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment