Unverified Commit 694a806d authored by Pierre-Elliott Bécue's avatar Pierre-Elliott Bécue 🚼
Browse files

Sends a bcc copy of the DOI of any DD_U, DD_NU process

parent b3b849db
Pipeline #252293 passed with stage
in 5 minutes and 21 seconds
......@@ -269,6 +269,9 @@ IDENTITIES_EXPORT_ALLOW_IPS = []
# If set, the RT API calls when a process if approved won't be done and a mock id will be returned
MOCK_RT = False
# Mail address of the Community Team
COMMUNITY_EMAIL = "community@debian.org"
# Try importing local settings from local_settings.py, if we can't, it's just fine, use defaults from this file
try:
from .local_settings import * # noqa
......
......@@ -62,7 +62,7 @@ the nm.debian.org housekeeping robot
msg.subject)
def notify_new_statement(statement, request=None, cc_nm=True, notify_ml="newmaint", mia=None, date=None):
def notify_new_statement(statement, request=None, cc_nm=True, notify_ml="newmaint", mia=None, date=None, bcc=None):
"""
Render a notification email template for a newly uploaded statement, then
send the resulting email.
......@@ -96,6 +96,9 @@ For details and to comment, visit {url}
if process.person.lookup_key != statement.uploaded_by.lookup_key:
cc.append(statement.uploaded_by)
if bcc is not None:
bcc = list(bcc)
headers = {}
if mia is not None:
headers["X-MIA-Summary"] = mia
......@@ -113,6 +116,7 @@ For details and to comment, visit {url}
from_email=(f"{statement.uploaded_by.fullname} (via nm.debian.org)", "nm@debian.org"),
to=to,
cc=cc,
bcc=bcc,
subject="{}: {}{}".format(
process.person.fullname,
statement.requirement.type_desc,
......
......@@ -386,11 +386,15 @@ class ProcessStatementAdd(op.Operation):
self.requirement.save()
def notify(self, request=None):
bcc = None
if self.requirement.type not in ("intent", "advocate", "am_ok"):
return
if (self.requirement.type == "intent" and
self.requirement.process.applying_for in [const.STATUS_DD_NU, const.STATUS_DD_U]):
bcc = [settings.COMMUNITY_EMAIL,]
from .email import notify_new_statement
notify_new_statement(self._statement, request=request, date=self.audit_time, cc_nm=(
self.requirement.type == "am_ok"), notify_ml="newmaint")
self.requirement.type == "am_ok"), notify_ml="newmaint", bcc=bcc)
@op.Operation.register
......
......@@ -153,7 +153,7 @@ class TestProcessStatementAdd(ProcessFixtureMixin, TestCase):
self.assertEqual(mail.outbox[0].to, ['debian-newmaint@lists.debian.org'])
self.assertEqual(mail.outbox[0].cc, ['App <app@example.org>', 'archive-1@nm.debian.org',
'Dam <dam@example.org>'])
self.assertEqual(mail.outbox[0].bcc, [])
self.assertEqual(mail.outbox[0].bcc, ['community@debian.org'])
self.assertEqual(mail.outbox[0].reply_to, ['debian-newmaint@lists.debian.org', 'App <app@example.org>',
'archive-1@nm.debian.org', 'Dam <dam@example.org>'])
self.assertEqual(mail.outbox[0].extra_headers, {'Date': 'Tue, 01 Jan 2019 00:00:00 -0000'})
......@@ -181,7 +181,7 @@ class TestProcessStatementAdd(ProcessFixtureMixin, TestCase):
'Dam <dam@example.org>'])
self.assertEqual(mail.outbox[0].reply_to, ['debian-newmaint@lists.debian.org', 'App <app@example.org>',
'archive-1@nm.debian.org', 'Dam <dam@example.org>'])
self.assertEqual(mail.outbox[0].bcc, [])
self.assertEqual(mail.outbox[0].bcc, ['community@debian.org'])
self.assertEqual(mail.outbox[0].extra_headers, {'Date': 'Tue, 01 Jan 2019 00:00:00 -0000'})
self.assertEqual(
mail.outbox[0].body,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment