[PATCH 4/5] models: Remove 'refresh_tag_counts' from Submission

Stephen Finucane stephen at that.guru
Tue Oct 11 09:44:49 AEDT 2016


Turns out 'Submission' has a 'patch' field when it's subclassed as
'Patch'. Use this field to call 'refresh_tag_counts' on the subclass
only.

Signed-off-by: Stephen Finucane <stephen at that.guru>
---
 patchwork/models.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/patchwork/models.py b/patchwork/models.py
index 608b70c..3abae3c 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -295,9 +295,6 @@ class Submission(EmailMixin, models.Model):
 
     # patchwork metadata
 
-    def refresh_tag_counts(self):
-        pass  # TODO(sfinucan) Once this is only called for patches, remove
-
     def is_editable(self, user):
         return False
 
@@ -549,11 +546,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']
-- 
2.7.4



More information about the Patchwork mailing list