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

Daniel Axtens dja at axtens.net
Thu Oct 13 10:30:46 AEDT 2016


Stephen Finucane <stephen at 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 <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()

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 at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork


More information about the Patchwork mailing list