]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
Report if a patch is delegated and to whom
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sat, 28 Nov 2015 12:14:43 +0000 (10:14 -0200)
committerStephen Finucane <stephen.finucane@intel.com>
Tue, 19 Jan 2016 21:22:31 +0000 (21:22 +0000)
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@intel.com>
Suggested-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
patchwork/tests/test_mboxviews.py
patchwork/views/__init__.py

index 9c82531215dde0d4002c8a7b1f7b97cd08924285..a2bee0d1e8729b7383c41f11c5e4fb58cfbc77da 100644 (file)
@@ -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']
 
index bf6cad150430dda91d4bc7be3c77daa1ccc965f3..0a12b41c12da35b9bb97b80eb6a3223e2c459ee3 100644 (file)
@@ -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())