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

Stephen Finucane stephen at that.guru
Thu Oct 13 21:13:02 AEDT 2016


On 2016-10-12 23:30, Daniel Axtens wrote:
> 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?

When you put it that way, there isn't one really (apart from being 
explicit, which is no real advantage). Maybe I should remove the TODO 
instead.

Stephen


More information about the Patchwork mailing list