-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtransactional_emails.py
27 lines (21 loc) · 1.05 KB
/
transactional_emails.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from utils.notify_helpers import send_email_with_body_from_user
from utils import setting_handler, models
from plugins.archive_plugin import plugin_settings
from django.template import Template, RequestContext, Context
def send_update_request_email(request, article):
"""
Generate and send email to article correspondence author notifying them of editor's update request
: article is an article object
"""
plugin = models.Plugin.objects.get(name=plugin_settings.SHORT_NAME)
subject = "{} Article Update Request: '{}'".format(article.journal.code, article.title)
to = article.correspondence_author.email
template = setting_handler.get_plugin_setting(plugin, 'request_email_template', request.journal).processed_value
template = template.replace('\r', '')
template = template.replace('\n', '')
context = {"article": article, "request": request}
template = Template(template)
con = RequestContext(request)
con.push(context)
body = template.render(con)
send_email_with_body_from_user(request, subject, to, body)