From d03c021c64494b6b98e419a952ee628c71c24cf6 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 28 Nov 2015 10:14:43 -0200 Subject: [PATCH] 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 --- patchwork/tests/test_mboxviews.py | 30 +++++++++++++++++++++++++++++- patchwork/views/__init__.py | 2 ++ 2 files changed, 31 insertions(+), 1 deletion(-) 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()) -- 2.47.3