Skip to content

Commit 866d14b

Browse files
ajdlinuxstephenfin
authored andcommitted
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 <[email protected]> Fixes: 86172cc ("models: Split Patch into two models") Closes-bug: #111 ("A/R/T not updated on comments") Signed-off-by: Andrew Donnellan <[email protected]> Reviewed-by: Stephen Finucane <[email protected]>
1 parent c4ad0d8 commit 866d14b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

patchwork/models.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,6 @@ class Submission(FilenameMixin, EmailMixin, models.Model):
350350

351351
# patchwork metadata
352352

353-
def refresh_tag_counts(self):
354-
# This is subclassed on 'Patch' to do something useful
355-
pass
356-
357353
def is_editable(self, user):
358354
return False
359355

@@ -578,11 +574,13 @@ class Comment(EmailMixin, models.Model):
578574

579575
def save(self, *args, **kwargs):
580576
super(Comment, self).save(*args, **kwargs)
581-
self.submission.refresh_tag_counts()
577+
if hasattr(self.submission, 'patch'):
578+
self.submission.patch.refresh_tag_counts()
582579

583580
def delete(self, *args, **kwargs):
584581
super(Comment, self).delete(*args, **kwargs)
585-
self.submission.refresh_tag_counts()
582+
if hasattr(self.submission, 'patch'):
583+
self.submission.patch.refresh_tag_counts()
586584

587585
class Meta:
588586
ordering = ['date']

0 commit comments

Comments
 (0)