Commit 7fdc3464 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Add option for additional todomail providers

/close #76
parent 6e6f7935
......@@ -157,3 +157,12 @@ LATEX_BULLETPOINTS = [
# optional: include header and footer in asta-style, not just a page number on top
#LATEX_HEADER_FOOTER = True
HTML_LEVEL_OFFSET = 3
def dummy_todomail_provider():
return {"example": ("Name", "mail@example.com")}
# list of functions that return dicts mapping todomail-keys to a tuple containing name and mail address
ADDITIONAL_TODOMAIL_PROVIDERS = [
dummy_todomail_provider
]
......@@ -611,8 +611,20 @@ def send_todomails_async(protocol_id):
for user in users
}
subject = "Du hast noch was zu tun!"
todomail_providers = getattr(config, "ADDITIONAL_TODOMAIL_PROVIDERS", None)
additional_todomails = {}
if todomail_providers:
for provider in todomail_providers:
todomail_dict = provider()
for key in todomail_dict:
if key not in additional_todomails:
name, mail = todomail_dict[key]
additional_todomails[key] = TodoMail(name, mail)
for user in users:
todomail = TodoMail.query.filter(TodoMail.name.ilike(user)).first()
if todomail is None:
if user in additional_todomails:
todomail = additional_todomails[user]
if todomail is None:
error = protocol.create_error("Sending Todomail", "Sending Todomail failed.", "User {} has no Todo-Mail-Assignment.".format(user))
db.session.add(error)
......
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