From patchwork Sat Nov 28 12:14:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 549635 X-Patchwork-Delegate: stephen.finucane@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CD75F1401F0 for ; Sat, 28 Nov 2015 23:15:24 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id B9BAD1A080F for ; Sat, 28 Nov 2015 23:15:24 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id E051E1A0452 for ; Sat, 28 Nov 2015 23:15:08 +1100 (AEDT) Received: from [179.182.162.78] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1a2ePB-0005Ch-Mt; Sat, 28 Nov 2015 12:15:06 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.86) (envelope-from ) id 1a2eOw-0001AM-Vy; Sat, 28 Nov 2015 10:14:50 -0200 From: Mauro Carvalho Chehab To: Subject: [PATCH 07/10] Report if a patch is delagated and to whom Date: Sat, 28 Nov 2015 10:14:43 -0200 Message-Id: <1448712886-3221-8-git-send-email-mchehab@osg.samsung.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1448712886-3221-1-git-send-email-mchehab@osg.samsung.com> References: <1448712886-3221-1-git-send-email-mchehab@osg.samsung.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Patchwork ML , Mauro Carvalho Chehab MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" 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: Mauro Carvalho Chehab --- patchwork/models.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/patchwork/models.py b/patchwork/models.py index e552217a3cbc..024ff4d8d5e1 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -323,6 +323,60 @@ class Patch(models.Model): str = fname_re.sub('-', self.name) return str.strip('-') + '.patch' + def mbox(self): + postscript_re = re.compile('\n-{2,3} ?\n') + + comment = None + try: + comment = Comment.objects.get(patch = self, msgid = self.msgid) + except Exception: + pass + + body = '' + if comment: + body = comment.content.strip() + "\n" + + parts = postscript_re.split(body, 1) + if len(parts) == 2: + (body, postscript) = parts + body = body.strip() + "\n" + postscript = postscript.strip() + "\n" + else: + postscript = '' + + for comment in Comment.objects.filter(patch = self) \ + .exclude(msgid = self.msgid): + body += comment.patch_responses() + + if body: + body += '\n' + + if postscript: + body += '---\n' + postscript.strip() + '\n' + + if self.content: + body += '\n' + self.content + + mail = PatchMbox(body) + mail['Subject'] = self.name + mail['Date'] = email.utils.formatdate( + time.mktime(self.date.utctimetuple())) + mail['From'] = unicode(self.submitter) + mail['X-Patchwork-Id'] = str(self.id) + if self.delegate: + mail['X-Patchwork-Delegate'] = str(self.delegate.email) + mail['Message-Id'] = self.msgid + mail.set_unixfrom('From patchwork ' + self.date.ctime()) + + + copied_headers = ['To', 'Cc'] + orig_headers = HeaderParser().parsestr(str(self.headers)) + for header in copied_headers: + if header in orig_headers: + mail[header] = orig_headers[header] + + return mail + @models.permalink def get_absolute_url(self): return ('patchwork.views.patch.patch', (), {'patch_id': self.id})