diff --git a/ietf/doc/mails.py b/ietf/doc/mails.py index e0d2d40cf..4cf2c8200 100644 --- a/ietf/doc/mails.py +++ b/ietf/doc/mails.py @@ -417,6 +417,20 @@ def email_last_call_expired(doc): url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url()), cc = addrs.cc) +def email_comment(request, doc, comment): + (to, cc) = gather_address_lists('doc_added_comment',doc=doc) + + send_mail(request, to, None, "Comment added to %s history"%doc.name, + "doc/mail/comment_added_email.txt", + dict( + comment=comment, + doc=doc, + by=request.user.person, + url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url(), + ), + cc = cc) + + def email_adopted(request, doc, prev_state, new_state, by, comment=""): (to, cc) = gather_address_lists('doc_adopted_by_group',doc=doc) diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index 82e16238d..06dd3f83c 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -718,8 +718,9 @@ class AddCommentTestCase(TestCase): self.assertEqual("This is a test.", draft.latest_event().desc) self.assertEqual("added_comment", draft.latest_event().type) self.assertEqual(len(outbox), mailbox_before + 1) - self.assertTrue("updated" in outbox[-1]['Subject']) + self.assertTrue("Comment added" in outbox[-1]['Subject']) self.assertTrue(draft.name in outbox[-1]['Subject']) + self.assertTrue('draft-ietf-mars-test@' in outbox[-1]['To']) # Make sure we can also do it as IANA self.client.login(username="iana", password="iana+password") diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 5b097876c..e60c1e0ff 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -58,7 +58,7 @@ from ietf.name.models import StreamName, BallotPositionName from ietf.person.models import Email from ietf.utils.history import find_history_active_at from ietf.doc.forms import TelechatForm, NotifyForm -from ietf.doc.mails import email_ad +from ietf.doc.mails import email_comment from ietf.mailtoken.utils import gather_relevant_expansions def render_document_top(request, doc, tab, name): @@ -906,10 +906,8 @@ def add_comment(request, name): e.desc = c e.save() - if doc.type_id == "draft": - # TODO - build an explicit message for when a comment is added - email_ad(request, doc, doc.ad, login, - "A new comment added by %s" % login.name) + email_comment(request, doc, e) + return redirect("doc_history", name=doc.name) else: form = AddCommentForm() diff --git a/ietf/mailtoken/migrations/0002_auto_20150809_1314.py b/ietf/mailtoken/migrations/0002_auto_20150809_1314.py index b3a6cf96c..06f4738cf 100644 --- a/ietf/mailtoken/migrations/0002_auto_20150809_1314.py +++ b/ietf/mailtoken/migrations/0002_auto_20150809_1314.py @@ -783,6 +783,15 @@ def make_mailtokens(apps): ], ) + mt_factory(slug='doc_added_comment', + desc="Recipients for a message when a new comment is manually entered into the document's history", + to_slugs=['doc_authors', + 'doc_group_chairs', + 'doc_shepherd', + 'doc_group_responsible_directors', + 'doc_non_ietf_stream_manager', + ]) + def forward(apps, schema_editor): diff --git a/ietf/name/fixtures/names.json b/ietf/name/fixtures/names.json index ddc958807..351ea48ea 100644 --- a/ietf/name/fixtures/names.json +++ b/ietf/name/fixtures/names.json @@ -4961,6 +4961,21 @@ "model": "mailtoken.mailtoken", "pk": "conflrev_requested_iana" }, +{ + "fields": { + "cc": [], + "to": [ + "doc_authors", + "doc_group_chairs", + "doc_group_responsible_directors", + "doc_non_ietf_stream_manager", + "doc_shepherd" + ], + "desc": "Recipients for a message when a new comment is manually entered into the document's history" + }, + "model": "mailtoken.mailtoken", + "pk": "doc_added_comment" +}, { "fields": { "cc": [ diff --git a/ietf/templates/doc/mail/comment_added_email.txt b/ietf/templates/doc/mail/comment_added_email.txt new file mode 100644 index 000000000..721c0e8e8 --- /dev/null +++ b/ietf/templates/doc/mail/comment_added_email.txt @@ -0,0 +1,12 @@ +{% autoescape off %} +Please DO NOT reply to this email. + +{{by}} added the following comment to the history of {{doc.name}} + +{{ comment.desc }} + +The document can be found at +I-D: {{ doc.file_tag|safe }} +ID Tracker URL: {{ url }} + +{% endautoescape%}