From: Andrew Donnellan Date: Sun, 20 Aug 2017 14:40:10 +0000 (+1000) Subject: models: Fix invocation of refresh_tag_counts() for Comments X-Git-Tag: v2.0.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=866d14b4c1ce64e20ec4d2e7b3dd7667188ab630;p=thirdparty%2Fpatchwork.git models: Fix invocation of refresh_tag_counts() for Comments 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 Fixes: 86172ccc161b ("models: Split Patch into two models") Closes-bug: #111 ("A/R/T not updated on comments") Signed-off-by: Andrew Donnellan Reviewed-by: Stephen Finucane --- diff --git a/patchwork/models.py b/patchwork/models.py index 56daea16..f8d24726 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -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']