From: Mauro Carvalho Chehab Date: Sat, 28 Nov 2015 12:14:43 +0000 (-0200) Subject: Report if a patch is delegated and to whom X-Git-Tag: v1.1.0~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d03c021c64494b6b98e419a952ee628c71c24cf6;p=thirdparty%2Fpatchwork.git Report if a patch is delegated and to whom When a patch is delegated, it can be important to report it via pwclient, as handing delegated patches may be different. So, add an optional field at the email's body if this is happening. Signed-off-by: Stephen Finucane Suggested-by: Mauro Carvalho Chehab --- diff --git a/patchwork/tests/test_mboxviews.py b/patchwork/tests/test_mboxviews.py index 9c825312..a2bee0d1 100644 --- a/patchwork/tests/test_mboxviews.py +++ b/patchwork/tests/test_mboxviews.py @@ -27,7 +27,7 @@ import email from django.test import TestCase from patchwork.models import Patch, Comment -from patchwork.tests.utils import defaults +from patchwork.tests.utils import defaults, create_user class MboxPatchResponseTest(TestCase): @@ -134,6 +134,34 @@ class MboxPassThroughHeaderTest(TestCase): self.assertContains(response, self.date_header) +class MboxGeneratedHeaderTest(TestCase): + fixtures = ['default_states'] + + def setUp(self): + defaults.project.save() + self.person = defaults.patch_author_person + self.person.save() + + self.user = create_user() + + self.patch = Patch(project=defaults.project, + msgid='p1', + name='testpatch', + submitter=self.person, + delegate=self.user, + content='') + self.patch.save() + + def testPatchworkIdHeader(self): + response = self.client.get('/patch/%d/mbox/' % self.patch.id) + self.assertContains(response, 'X-Patchwork-Id: %d' % self.patch.id) + + def testPatchworkDelegateHeader(self): + response = self.client.get('/patch/%d/mbox/' % self.patch.id) + self.assertContains(response, + 'X-Patchwork-Delegate: %s' % self.user.email) + + class MboxBrokenFromHeaderTest(TestCase): fixtures = ['default_states'] diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py index bf6cad15..0a12b41c 100644 --- a/patchwork/views/__init__.py +++ b/patchwork/views/__init__.py @@ -207,6 +207,8 @@ def patch_to_mbox(patch): str(Header(patch.submitter.name, mail.patch_charset)), patch.submitter.email)) mail['X-Patchwork-Id'] = str(patch.id) + if patch.delegate: + mail['X-Patchwork-Delegate'] = str(patch.delegate.email) mail['Message-Id'] = patch.msgid mail.set_unixfrom('From patchwork ' + patch.date.ctime())