Allow removing a document shepherd, and test that it works. Fixes bug #1509. Commit ready for merge.

- Legacy-Id: 8505
This commit is contained in:
Robert Sparks 2014-10-27 21:27:49 +00:00
parent 905df236c3
commit 0496ee1b73
2 changed files with 8 additions and 1 deletions

View file

@ -851,8 +851,15 @@ class IndividualInfoFormsTests(TestCase):
# save the form without changing the email (nothing should be saved)
r = self.client.post(url, dict(shepherd=plain_email.pk))
self.assertEqual(r.status_code, 302)
self.doc = Document.objects.get(name=self.docname)
self.assertEqual(set(comment_events), set(self.doc.docevent_set.filter(time=self.doc.time,type="added_comment")))
# Remove the shepherd
r = self.client.post(url, dict(shepherd=''))
self.assertEqual(r.status_code, 302)
self.doc = Document.objects.get(name=self.docname)
self.assertTrue(any(['Document shepherd changed to (None)' in x.desc for x in self.doc.docevent_set.filter(time=self.doc.time,type='added_comment')]))
# test buggy change
ad = Person.objects.get(name='Aread Irector')
two_answers = "%s,%s" % (plain_email, ad.email_set.all()[0])

View file

@ -966,7 +966,7 @@ def edit_shepherd(request, name):
c.desc = "Document shepherd changed to "+ (doc.shepherd.person.name if doc.shepherd else "(None)")
c.save()
if doc.shepherd.formatted_email() not in doc.notify:
if doc.shepherd and (doc.shepherd.formatted_email() not in doc.notify):
login = request.user.person
addrs = doc.notify
if addrs: