Stephen Finucane <step...@that.guru> writes: > 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 <step...@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()
This seems more complex than what it replaces. Apart from avoiding an empty method in the Submission model, what's the benefit? Regards, Daniel > > class Meta: > ordering = ['date'] > -- > 2.7.4 > > _______________________________________________ > Patchwork mailing list > Patchwork@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/patchwork _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork