From d4e5f070aff73eb95814793d9da5d44868eecbd0 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sun, 12 Oct 2014 17:32:11 +0000 Subject: [PATCH] Merged in [8293] from rjsparks@nostrum.com:\n XXX: Should what is now captured in the list of STATUSCHANGE_RELATIONS instead be captured in the database in name_docrelationshipname? Refactored editing the notify field to remove redundant code. Changed the default notification list to include .all for documents, and the wg list for wg documents. Allowed recalculating the notification list for all document types. Improved the calculated notification list value for charters, conflict-reviews, and status-changes. Adds shepherds to the notification list when they are assigned to a document. Adds the working group email list to the notification list when a document is adopted. Fixes #1438 - Legacy-Id: 8385 Note: SVN reference [8293] has been migrated to Git commit 640c5eb52ace8bb6d2c1b3ca6c14ef10ad0f324f --- ietf/doc/forms.py | 6 +- ietf/doc/models.py | 2 + ietf/doc/tests_charter.py | 16 +++- ietf/doc/tests_conflict_review.py | 12 ++- ietf/doc/tests_draft.py | 11 ++- ietf/doc/tests_status_change.py | 18 ++++- ietf/doc/urls.py | 2 +- ietf/doc/urls_charter.py | 2 +- ietf/doc/urls_conflict_review.py | 2 +- ietf/doc/urls_status_change.py | 2 +- ietf/doc/utils.py | 72 ++++++++++++++++- ietf/doc/views_charter.py | 43 ---------- ietf/doc/views_conflict_review.py | 37 +-------- ietf/doc/views_doc.py | 56 +++++++++++-- ietf/doc/views_draft.py | 81 ++++--------------- ietf/doc/views_status_change.py | 58 +++---------- ietf/templates/doc/charter/edit_notify.html | 32 -------- .../change_notify.html => edit_notify.html} | 4 +- ietf/templates/doc/notify.html | 42 ---------- ietf/utils/test_data.py | 1 + 20 files changed, 216 insertions(+), 283 deletions(-) delete mode 100644 ietf/templates/doc/charter/edit_notify.html rename ietf/templates/doc/{draft/change_notify.html => edit_notify.html} (85%) delete mode 100644 ietf/templates/doc/notify.html diff --git a/ietf/doc/forms.py b/ietf/doc/forms.py index 2058d86bd..8bb4a1b73 100644 --- a/ietf/doc/forms.py +++ b/ietf/doc/forms.py @@ -34,4 +34,8 @@ class AdForm(forms.Form): self.fields['ad'].choices = list(choices) + [("", "-------"), (ad_pk, Person.objects.get(pk=ad_pk).plain_name())] class NotifyForm(forms.Form): - notify = forms.CharField(max_length=255, label="Notice emails", help_text="Separate email addresses with commas", required=False) + notify = forms.CharField(max_length=255, help_text="List of email addresses to receive state notifications, separated by comma", label="Notification list", required=False) + + def clean_notify(self): + addrspecs = [x.strip() for x in self.cleaned_data["notify"].split(',')] + return ', '.join(addrspecs) diff --git a/ietf/doc/models.py b/ietf/doc/models.py index 99f968375..18275c6c3 100644 --- a/ietf/doc/models.py +++ b/ietf/doc/models.py @@ -178,6 +178,8 @@ class DocumentInfo(models.Model): class Meta: abstract = True +STATUSCHANGE_RELATIONS = ('tops','tois','tohist','toinf','tobcp','toexp') + class RelatedDocument(models.Model): source = models.ForeignKey('Document') target = models.ForeignKey('DocAlias') diff --git a/ietf/doc/tests_charter.py b/ietf/doc/tests_charter.py index 5e36e6da6..a3b9565dd 100644 --- a/ietf/doc/tests_charter.py +++ b/ietf/doc/tests_charter.py @@ -181,11 +181,23 @@ class EditCharterTests(TestCase): # post self.assertTrue(not charter.notify) - r = self.client.post(url, dict(notify="someone@example.com, someoneelse@example.com")) + newlist = "someone@example.com, someoneelse@example.com" + r = self.client.post(url, dict(notify=newlist,save_addresses="1")) self.assertEqual(r.status_code, 302) charter = Document.objects.get(name=charter.name) - self.assertEqual(charter.notify, "someone@example.com, someoneelse@example.com") + self.assertEqual(charter.notify, newlist) + + # Ask the form to regenerate the list + r = self.client.post(url,dict(regenerate_addresses="1")) + self.assertEqual(r.status_code,200) + charter= Document.objects.get(name=charter.name) + # Regenerate does not save! + self.assertEqual(charter.notify,newlist) + q = PyQuery(r.content) + formlist = q('form input[name=notify]')[0].value + self.assertTrue('marschairman@ietf.org' in formlist) + self.assertFalse('someone@example.com' in formlist) def test_edit_ad(self): make_test_data() diff --git a/ietf/doc/tests_conflict_review.py b/ietf/doc/tests_conflict_review.py index 63557550a..6a4dc6ff0 100644 --- a/ietf/doc/tests_conflict_review.py +++ b/ietf/doc/tests_conflict_review.py @@ -176,12 +176,22 @@ class ConflictReviewTests(TestCase): # change notice list newlist = '"Foo Bar" ' - r = self.client.post(url,dict(notify=newlist)) + r = self.client.post(url,dict(notify=newlist,save_addresses="1")) self.assertEqual(r.status_code,302) doc = Document.objects.get(name='conflict-review-imaginary-irtf-submission') self.assertEqual(doc.notify,newlist) self.assertTrue(doc.latest_event(DocEvent,type="added_comment").desc.startswith('Notification list changed')) + # Ask the form to regenerate the list + r = self.client.post(url,dict(regenerate_addresses="1")) + self.assertEqual(r.status_code,200) + doc = Document.objects.get(name='conflict-review-imaginary-irtf-submission') + # Regenerate does not save! + self.assertEqual(doc.notify,newlist) + q = PyQuery(r.content) + self.assertTrue('draft-imaginary-irtf-submission@tools.ietf.org' in q('form input[name=notify]')[0].value) + self.assertTrue('irtf-chair@ietf.org' in q('form input[name=notify]')[0].value) + self.assertTrue('foo@bar.baz.com' not in q('form input[name=notify]')[0].value) def test_edit_ad(self): doc = Document.objects.get(name='conflict-review-imaginary-irtf-submission') diff --git a/ietf/doc/tests_draft.py b/ietf/doc/tests_draft.py index d69274488..4e33a1514 100644 --- a/ietf/doc/tests_draft.py +++ b/ietf/doc/tests_draft.py @@ -841,7 +841,9 @@ class IndividualInfoFormsTests(TestCase): self.assertEqual(r.status_code,302) self.doc = Document.objects.get(name=self.docname) self.assertEqual(self.doc.shepherd,plain) - self.assertTrue(self.doc.latest_event(DocEvent,type="added_comment").desc.startswith('Document shepherd changed to Plain Man')) + comments = '::'.join([x.desc for x in self.doc.docevent_set.filter(time=self.doc.time,type="added_comment")]) + self.assertTrue('Document shepherd changed to Plain Man' in comments) + self.assertTrue('Notification list changed' in comments) ad = Person.objects.get(name='Aread Irector') two_answers = "%s,%s" % (plain_email, ad.email_set.all()[0]) @@ -1021,16 +1023,19 @@ class AdoptDraftTests(TestCase): # adopt in mars WG mailbox_before = len(outbox) events_before = draft.docevent_set.count() + mars = Group.objects.get(acronym="mars") r = self.client.post(url, dict(comment="some comment", - group=Group.objects.get(acronym="mars").pk, + group=mars.pk, weeks="10")) self.assertEqual(r.status_code, 302) draft = Document.objects.get(pk=draft.pk) self.assertEqual(draft.group.acronym, "mars") self.assertEqual(draft.stream_id, "ietf") - self.assertEqual(draft.docevent_set.count() - events_before, 4) + self.assertEqual(draft.docevent_set.count() - events_before, 5) + self.assertTrue(mars.list_email in draft.notify) + self.assertTrue('draft-ietf-mars-test.all@tools.ietf.org' in draft.notify) self.assertEqual(len(outbox), mailbox_before + 1) self.assertTrue("state changed" in outbox[-1]["Subject"].lower()) self.assertTrue("marschairman@ietf.org" in unicode(outbox[-1])) diff --git a/ietf/doc/tests_status_change.py b/ietf/doc/tests_status_change.py index 0ca2768f7..2cb95b99e 100644 --- a/ietf/doc/tests_status_change.py +++ b/ietf/doc/tests_status_change.py @@ -139,12 +139,28 @@ class StatusChangeTests(TestCase): # change notice list newlist = '"Foo Bar" ' - r = self.client.post(url,dict(notify=newlist)) + r = self.client.post(url,dict(notify=newlist,save_addresses="1")) self.assertEqual(r.status_code,302) doc = Document.objects.get(name='status-change-imaginary-mid-review') self.assertEqual(doc.notify,newlist) self.assertTrue(doc.latest_event(DocEvent,type="added_comment").desc.startswith('Notification list changed')) + # Some additional setup so there's something to put in a generated notify list + doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9999'),relationship_id='tois') + doc.relateddocument_set.create(target=DocAlias.objects.get(name='rfc9998'),relationship_id='tohist') + + # Ask the form to regenerate the list + r = self.client.post(url,dict(regenerate_addresses="1")) + self.assertEqual(r.status_code,200) + doc = Document.objects.get(name='status-change-imaginary-mid-review') + # Regenerate does not save! + self.assertEqual(doc.notify,newlist) + q = PyQuery(r.content) + formlist = q('form input[name=notify]')[0].value + self.assertTrue('draft-ietf-random-thing@ietf.org' in formlist) + self.assertTrue('draft-ietf-random-otherthing@ietf.org' in formlist) + self.assertFalse('foo@bar.baz.com' in formlist) + def test_edit_title(self): doc = Document.objects.get(name='status-change-imaginary-mid-review') url = urlreverse('status_change_title',kwargs=dict(name=doc.name)) diff --git a/ietf/doc/urls.py b/ietf/doc/urls.py index 940307d2a..c203c764a 100644 --- a/ietf/doc/urls.py +++ b/ietf/doc/urls.py @@ -74,7 +74,7 @@ urlpatterns = patterns('', url(r'^(?P[A-Za-z0-9._+-]+)/edit/stream/$', views_draft.change_stream, name='doc_change_stream'), url(r'^(?P[A-Za-z0-9._+-]+)/edit/replaces/$', views_draft.replaces, name='doc_change_replaces'), - url(r'^(?P[A-Za-z0-9._+-]+)/edit/notify/$', views_draft.edit_notices, name='doc_change_notify'), + url(r'^(?P[A-Za-z0-9._+-]+)/edit/notify/$', views_doc.edit_notify, name='doc_change_notify'), url(r'^(?P[A-Za-z0-9._+-]+)/edit/status/$', views_draft.change_intention, name='doc_change_intended_status'), url(r'^(?P[A-Za-z0-9._+-]+)/edit/telechat/$', views_doc.telechat_date, name='doc_change_telechat_date'), url(r'^(?P[A-Za-z0-9._+-]+)/edit/iesgnote/$', views_draft.edit_iesg_note, name='doc_change_iesg_note'), diff --git a/ietf/doc/urls_charter.py b/ietf/doc/urls_charter.py index 372a4a1b1..b98748845 100644 --- a/ietf/doc/urls_charter.py +++ b/ietf/doc/urls_charter.py @@ -6,7 +6,7 @@ urlpatterns = patterns('', url(r'^state/$', "ietf.doc.views_charter.change_state", name='charter_change_state'), url(r'^(?P