]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/models.py
[views] Restructure profile view, simplify bundle access
[patchwork] / apps / patchwork / models.py
index e516be29d6730664f0a027248d9ec56dcfb9222e..bf8efba20b6c0cf788d5e014951f20bfd50ee32d 100644 (file)
@@ -220,13 +220,22 @@ class Patch(models.Model):
     def mbox(self):
         comment = None
         try:
-            comment = Comment.objects.get(msgid = self.msgid)
+            comment = Comment.objects.get(patch = self, msgid = self.msgid)
         except Exception:
             pass
 
         body = ''
         if comment:
-            body = comment.content.strip() + "\n\n"
+            body = comment.content.strip() + "\n"
+
+        responses = False
+        for comment in Comment.objects.filter(patch = self) \
+                .exclude(msgid = self.msgid):
+            body += comment.patch_responses()
+
+        if body:
+            body += '\n'
+
         body += self.content
 
         mail = MIMEText(body)
@@ -256,6 +265,12 @@ class Comment(models.Model):
     headers = models.TextField(blank = True)
     content = models.TextField()
 
+    response_re = re.compile('^(Acked|Signed-off|Nacked)-by: .*$', re.M)
+
+    def patch_responses(self):
+        return ''.join([ match.group(0) + '\n' for match in \
+                                self.response_re.finditer(self.content)])
+
     class Meta:
         ordering = ['date']
 
@@ -308,6 +323,7 @@ class UserPersonConfirmation(models.Model):
         person.link_to_user(self.user)
         person.save()
         self.active = False
+        self.save()
 
     def save(self):
         max = 1 << 32