Send Email via the API

- uses the new subject/email from fields present on the templates / service tables
- brings the send email api call into line with the sms one.
- same fields (to/template_id)
- same rules regarding restricted services
- wired in as a task into celery

Requires
- new celery queue
- new env property (NOTIFY_EMAIL_DOMAIN)
This commit is contained in:
Martyn Inglis
2016-02-22 17:17:29 +00:00
parent dbe914f401
commit b01782bbe6
11 changed files with 399 additions and 88 deletions

View File

@@ -1,5 +1,5 @@
import os
import re
from flask import request, url_for
from flask import Flask, _request_ctx_stack
from flask.ext.sqlalchemy import SQLAlchemy
@@ -92,3 +92,10 @@ def get_db_version():
return full_name.split('_')[0]
except:
return 'n/a'
def email_safe(string):
return "".join([
character.lower() if character.isalnum() or character == "." else ""
for character in re.sub("\s+", ".", string.strip())
])