From 43374969f6a308356c0afb0264f5cf3b7899a32f Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Sat, 3 Nov 2018 08:13:10 +0000 Subject: [PATCH] Notify the RFC Editor when an RFC Editor note is changed after a draft has been approved. Fixes #2440. Commit ready for merge. - Legacy-Id: 15698 --- ietf/doc/tests_ballot.py | 12 ++++++++ ietf/doc/views_ballot.py | 13 +++++++++ ...llot_rfceditornote_changed_postapproval.py | 29 +++++++++++++++++++ ietf/name/fixtures/names.json | 23 ++++++++++++++- .../doc/ballot/ednote_changed_late.txt | 8 +++++ 5 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 ietf/mailtrigger/migrations/0004_ballot_rfceditornote_changed_postapproval.py create mode 100644 ietf/templates/doc/ballot/ednote_changed_late.txt diff --git a/ietf/doc/tests_ballot.py b/ietf/doc/tests_ballot.py index e249f9aec..535bbd806 100644 --- a/ietf/doc/tests_ballot.py +++ b/ietf/doc/tests_ballot.py @@ -395,6 +395,7 @@ class BallotWriteupsTests(TestCase): self.assertTrue("This is a note for the RFC Editor" in r.content) # save with a note + empty_outbox() r = self.client.post(url, dict( rfc_editor_note="This is a simple test.", save_ballot_rfceditornote="1")) @@ -402,6 +403,7 @@ class BallotWriteupsTests(TestCase): draft = Document.objects.get(name=draft.name) self.assertTrue(draft.has_rfc_editor_note()) self.assertTrue("This is a simple test" in draft.latest_event(WriteupDocEvent, type="changed_rfc_editor_note_text").text) + self.assertEqual(len(outbox), 0) # clear the existing note r = self.client.post(url, dict( @@ -411,6 +413,16 @@ class BallotWriteupsTests(TestCase): draft = Document.objects.get(name=draft.name) self.assertFalse(draft.has_rfc_editor_note()) + # Add a note after the doc is approved + empty_outbox() + draft.set_state(State.objects.get(type='draft-iesg',slug='approved')) + r = self.client.post(url, dict( + rfc_editor_note='This is a new note.', + save_ballot_rfceditornote="1")) + self.assertEqual(r.status_code, 200) + self.assertEqual(len(outbox),1) + self.assertIn('RFC Editor note changed',outbox[-1]['Subject']) + def test_issue_ballot(self): ad = Person.objects.get(user__username="ad") draft = IndividualDraftFactory(ad=ad) diff --git a/ietf/doc/views_ballot.py b/ietf/doc/views_ballot.py index dc5b1ede7..aca61804c 100644 --- a/ietf/doc/views_ballot.py +++ b/ietf/doc/views_ballot.py @@ -683,6 +683,19 @@ def ballot_rfceditornote(request, name): e.text = t.rstrip() e.save() + if doc.get_state_slug('draft-iesg') in ['approved', 'ann', 'rfcqueue']: + (to, cc) = gather_address_lists('ballot_ednote_changed_late').as_strings() + msg = render_to_string( + 'doc/ballot/ednote_changed_late.txt', + context = dict( + to = to, + cc = cc, + event = e, + settings = settings, + ) + ) + send_mail_preformatted(request, msg) + if request.method == 'POST' and "clear_ballot_rfceditornote" in request.POST: e = WriteupDocEvent(doc=doc, rev=doc.rev, by=login) e.by = login diff --git a/ietf/mailtrigger/migrations/0004_ballot_rfceditornote_changed_postapproval.py b/ietf/mailtrigger/migrations/0004_ballot_rfceditornote_changed_postapproval.py new file mode 100644 index 000000000..592afe92b --- /dev/null +++ b/ietf/mailtrigger/migrations/0004_ballot_rfceditornote_changed_postapproval.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.16 on 2018-11-03 00:24 +from __future__ import unicode_literals + +from django.db import migrations + +def forward(apps, schema_editor): + MailTrigger = apps.get_model('mailtrigger', 'MailTrigger') + Recipient = apps.get_model('mailtrigger', 'Recipient') + + changed = MailTrigger.objects.create( + slug = 'ballot_ednote_changed_late', + desc = 'Recipients when the RFC Editor note for a document is changed after the document has been approved', + ) + changed.to.set(Recipient.objects.filter(slug__in=['rfc_editor','iesg'])) + +def reverse(apps, schema_editor): + MailTrigger = apps.get_model('mailtrigger','MailTrigger') + MailTrigger.objects.filter(slug='ballot_ednote_changed_late').delete() + +class Migration(migrations.Migration): + + dependencies = [ + ('mailtrigger', '0003_add_review_notify_ad'), + ] + + operations = [ + migrations.RunPython(forward, reverse) + ] diff --git a/ietf/name/fixtures/names.json b/ietf/name/fixtures/names.json index da0f8d459..4cdf3826e 100644 --- a/ietf/name/fixtures/names.json +++ b/ietf/name/fixtures/names.json @@ -9282,6 +9282,14 @@ "template": "{{review_req.doc.group.list_email}}" } }, +{ + "model": "mailtrigger.recipient", + "pk": "review_team_ads", + "fields": { + "desc": "The ADs of the team reviewing the document", + "template": null + } +}, { "model": "mailtrigger.recipient", "pk": "review_team_mail_list", @@ -9483,6 +9491,18 @@ "cc": [] } }, +{ + "model": "mailtrigger.mailtrigger", + "pk": "ballot_ednote_changed_late", + "fields": { + "desc": "Recipients when the RFC Editor note for a document is changed after the document has been approved", + "to": [ + "iesg", + "rfc_editor" + ], + "cc": [] + } +}, { "model": "mailtrigger.mailtrigger", "pk": "ballot_issued", @@ -10305,7 +10325,8 @@ "fields": { "desc": "Recipients when a team notifies area directors when a review with one of a certain set of results (typically results indicating problem) is submitted", "to": [ - "review_doc_ad" + "review_doc_ad", + "review_team_ads" ], "cc": [] } diff --git a/ietf/templates/doc/ballot/ednote_changed_late.txt b/ietf/templates/doc/ballot/ednote_changed_late.txt new file mode 100644 index 000000000..cb0a42ed5 --- /dev/null +++ b/ietf/templates/doc/ballot/ednote_changed_late.txt @@ -0,0 +1,8 @@ +{% load ietf_filters %}{% autoescape off %}To: {{to}}{% if cc %} +Cc: {{cc}}{% endif %} +Subject: RFC Editor note changed for {{event.doc}} + +The RFC Editor note for {{event.doc}} has changed after the doc was approved. + +The new note can be seen at {{settings.IDTRACKER_BASE_URL}}{% url 'ietf.doc.views_doc.document_writeup' name=event.doc.name %} +{% endautoescape %} \ No newline at end of file