Files
@ 6139a13fde7a
Branch filter:
Location: website/conservancy/usethesource/emails.py - annotation
6139a13fde7a
2.0 KiB
text/x-python
Add payment time column to Stripe export
c287dac43303 cadd69061f18 3cccc3bdd90e 3cccc3bdd90e c287dac43303 c287dac43303 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e a7517825a3cc 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 3cccc3bdd90e 9158aff702ed 3cccc3bdd90e 3cccc3bdd90e cadd69061f18 cadd69061f18 cadd69061f18 3cccc3bdd90e c287dac43303 c287dac43303 cadd69061f18 3cccc3bdd90e 3cccc3bdd90e c287dac43303 c287dac43303 c287dac43303 a7517825a3cc c287dac43303 c287dac43303 c287dac43303 c287dac43303 9158aff702ed cadd69061f18 cadd69061f18 cadd69061f18 cadd69061f18 cadd69061f18 cadd69061f18 | from django.conf import settings
from django.core.mail import EmailMessage
from django.shortcuts import reverse
SENDER = settings.USETHESOURCE['SENDER']
LIST_RECIPIENT = settings.USETHESOURCE['LIST_RECIPIENT']
def make_candidate_email(candidate, user):
"""The initial email announcing the new candidate."""
subject = candidate.name
signature = user.get_full_name() or user.username
sender = f'{signature} <{SENDER}>'
to = [LIST_RECIPIENT]
body = f'''\
We've just published the following new candidate:
{candidate.name}
Vendor: {candidate.vendor}
Device: {candidate.device}
Released: {candidate.release_date}
{candidate.description}
To view this candidate and download the source candidate and firmware image, visit:
https://sfconservancy.org{reverse('usethesource:candidate', kwargs={'slug': candidate.slug})}
--
{signature}
(Via https://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."""
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}
To view this candidate and download the source candidate and firmware image, visit:
https://sfconservancy.org{reverse('usethesource:candidate', kwargs={'slug': candidate.slug})}
--
{signature}
(Via https://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
# email threading in Thunderbind. Sticking to "In-Reply-To" for now.
headers['In-Reply-To'] = in_reply_to
return EmailMessage(subject, body, sender, to, headers=headers)
|