diff --git a/conservancy/usethesource/emails.py b/conservancy/usethesource/emails.py index 8fde9d6f261dfae3fe48bca30c86f2550ea385ed..082e10dbb405112b4bfa796d0dba07c2146f842e 100644 --- a/conservancy/usethesource/emails.py +++ b/conservancy/usethesource/emails.py @@ -1,11 +1,42 @@ from django.core.mail import EmailMessage +from django.shortcuts import reverse + +SENDER = 'compliance@sfconservancy.org' +LIST_RECIPIENT = 'nutbush@lists.sfconservancy.org' + + +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 download this candidate's source and binary image, visit: +https://sfconservancy.org{reverse('usethesource:candidate', kwargs={'slug': candidate.slug})} + +-- +{signature} +''' + 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}' signature = comment.user.get_full_name() or comment.user.username - sender = f'{signature} ' - to = ['nutbush@lists.sfconservancy.org'] + sender = f'{signature} <{SENDER}>' + to = [LIST_RECIPIENT] body = f'{comment.message}\n\n--\n{signature}' headers = {'Message-ID': comment.email_message_id} if in_reply_to := comment.in_reply_to():