usethesource: Make email addresses configurable
This commit is contained in:
parent
8f58ae83e0
commit
c287dac433
2 changed files with 21 additions and 6 deletions
|
@ -149,3 +149,8 @@ MIDDLEWARE = [
|
|||
'conservancy.middleware.ForceCanonicalHostnameMiddleware',
|
||||
# 'django.middleware.doc.XViewMiddleware',
|
||||
]
|
||||
|
||||
USETHESOURCE = {
|
||||
'SENDER': 'compliance@sfconservancy.org',
|
||||
'LIST_RECIPIENT': 'nutbush@lists.sfconservancy.org',
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
from django.conf import settings
|
||||
from django.core.mail import EmailMessage
|
||||
from django.shortcuts import reverse
|
||||
|
||||
SENDER = 'compliance@sfconservancy.org'
|
||||
LIST_RECIPIENT = 'nutbush@lists.sfconservancy.org'
|
||||
SENDER = settings.USETHESOURCE['SENDER']
|
||||
LIST_RECIPIENT = settings.USETHESOURCE['LIST_RECIPIENT']
|
||||
|
||||
|
||||
def make_candidate_email(candidate, user):
|
||||
|
@ -21,23 +22,32 @@ Released: {candidate.release_date}
|
|||
|
||||
{candidate.description}
|
||||
|
||||
To download this candidate's source and binary image, visit:
|
||||
To view this candidate and download the source and binary image, visit:
|
||||
https://sfconservancy.org{reverse('usethesource:candidate', kwargs={'slug': candidate.slug})}
|
||||
|
||||
--
|
||||
{signature}
|
||||
'''
|
||||
(Via http//sfconservancy.org{reverse('usethesource:landing')})'''
|
||||
headers = {'Message-ID': candidate.email_message_id}
|
||||
return EmailMessage(subject, body, sender, to, headers=headers)
|
||||
|
||||
|
||||
def make_comment_email(comment):
|
||||
"""Email when a comment is added to a candidate."""
|
||||
subject = f'Re: {comment.candidate.name}'
|
||||
candidate = comment.candidate
|
||||
subject = f'Re: {candidate.name}'
|
||||
signature = comment.user.get_full_name() or comment.user.username
|
||||
sender = f'{signature} <{SENDER}>'
|
||||
to = [LIST_RECIPIENT]
|
||||
body = f'{comment.message}\n\n--\n{signature}'
|
||||
body = f'''\
|
||||
{comment.message}
|
||||
|
||||
To view this candidate and download the source and binary image, visit:
|
||||
https://sfconservancy.org{reverse('usethesource:candidate', kwargs={'slug': candidate.slug})}
|
||||
|
||||
--
|
||||
{signature}
|
||||
(Via http//sfconservancy.org{reverse('usethesource:landing')})'''
|
||||
headers = {'Message-ID': comment.email_message_id}
|
||||
if in_reply_to := comment.in_reply_to():
|
||||
# From my testing, both "In-Reply-To" and "References" headers trigger
|
||||
|
|
Loading…
Reference in a new issue