[PATCH 11/n] Report if a patch is delegated and to whom
Stephen Finucane
stephen.finucane at intel.com
Tue Jan 19 06:06:10 AEDT 2016
From: Mauro Carvalho Chehab <mchehab at osg.samsung.com>
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 <stephen.finucane at intel.com>
Suggested-by: Mauro Carvalho Chehab <mchehab at osg.samsung.com>
---
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 9c82531..a2bee0d 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 bf6cad1..0a12b41 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.0.0
More information about the Patchwork
mailing list