diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2019-09-05 13:16:52 +0100 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2019-09-05 13:16:52 +0100 |
| commit | b92cac0254c1014f4873343c38fc5b6ccbe3337d (patch) | |
| tree | a4cac96ac91a5b60900aa6b790a2685c29044918 /app/main/email.py | |
| parent | Change percentage to percentage of target (diff) | |
| download | AnnotateChange-b92cac0254c1014f4873343c38fc5b6ccbe3337d.tar.gz AnnotateChange-b92cac0254c1014f4873343c38fc5b6ccbe3337d.zip | |
Email the annotation record as a backup
Diffstat (limited to 'app/main/email.py')
| -rw-r--r-- | app/main/email.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/main/email.py b/app/main/email.py new file mode 100644 index 0000000..c10e234 --- /dev/null +++ b/app/main/email.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +import json + +from flask import current_app, render_template + +from app.email import send_email + + +def send_annotation_backup(record): + pretty_record = json.dumps(record, sort_keys=True, indent=4) + subject = "[Backup] New Annotation Recorded" + if current_app.debug: + subject += " (debug)" + send_email( + subject, + sender=current_app.config["ADMINS"][0], + recipients=[current_app.config["ADMINS"][0]], + text_body=render_template( + "email/annotation_record.txt", pretty_record=pretty_record + ), + html_body=render_template( + "email/annotation_record.html", pretty_record=pretty_record + ), + ) |
