]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
models: Fix invocation of refresh_tag_counts() for Comments
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Sun, 20 Aug 2017 14:40:10 +0000 (00:40 +1000)
committerStephen Finucane <stephen@that.guru>
Wed, 23 Aug 2017 16:19:00 +0000 (17:19 +0100)
In Comment.save() and Comment.delete(), we always call
Submission.refresh_tag_counts(), which is an empty stub, rather than
calling Patch.refresh_tag_counts() if the Submission is a Patch.

As such, tag counts are never updated on incoming comments.

Delete Submission.refresh_tag_counts(), as it's useless, and in
Comment.save()/delete(), invoke Patch.refresh_tag_counts() directly when
the submission is a Patch.

Reported-by: David Demelier <markand@malikania.fr>
Fixes: 86172ccc161b ("models: Split Patch into two models")
Closes-bug: #111 ("A/R/T not updated on comments")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
patchwork/models.py

index 56daea166bc4d5d36c0c29c16a9f7f779c670eb3..f8d24726756e8f3f1ac71d4321488cdfb073d6f8 100644 (file)
@@ -350,10 +350,6 @@ class Submission(FilenameMixin, EmailMixin, models.Model):
 
     # patchwork metadata
 
-    def refresh_tag_counts(self):
-        # This is subclassed on 'Patch' to do something useful
-        pass
-
     def is_editable(self, user):
         return False
 
@@ -578,11 +574,13 @@ class Comment(EmailMixin, models.Model):
 
     def save(self, *args, **kwargs):
         super(Comment, self).save(*args, **kwargs)
-        self.submission.refresh_tag_counts()
+        if hasattr(self.submission, 'patch'):
+            self.submission.patch.refresh_tag_counts()
 
     def delete(self, *args, **kwargs):
         super(Comment, self).delete(*args, **kwargs)
-        self.submission.refresh_tag_counts()
+        if hasattr(self.submission, 'patch'):
+            self.submission.patch.refresh_tag_counts()
 
     class Meta:
         ordering = ['date']