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 <[email protected]> --- 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}) -- 2.5.0 _______________________________________________ Patchwork mailing list [email protected] https://lists.ozlabs.org/listinfo/patchwork
