Message ID | 20170820144011.9583-1-andrew.donnellan@au1.ibm.com |
---|---|
State | Accepted |
Headers | show |
On 21/08/17 00:40, Andrew Donnellan wrote: > 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 <markand@malikania.fr> > Fixes: 86172ccc161b ("models: Split Patch into two models") > Closes-bug: #111 ("A/R/T not updated on comments") > Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Stephen - is this the last bug that's blocking the release? Happy to look at any other remaining blockers. I've pushed this fix to py{2,3}.patchwork.dja.id.au.
On Tue, 2017-08-22 at 12:47 +1000, Andrew Donnellan wrote: > On 21/08/17 00:40, Andrew Donnellan wrote: > > 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 <markand@malikania.fr> > > Fixes: 86172ccc161b ("models: Split Patch into two models") > > Closes-bug: #111 ("A/R/T not updated on comments") > > Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> > > Stephen - is this the last bug that's blocking the release? Happy to > look at any other remaining blockers. > > I've pushed this fix to py{2,3}.patchwork.dja.id.au. Yup, this looks good to me. Reviewed-by: Stephen Finucane <stephen@that.guru> Stephen
diff --git a/patchwork/models.py b/patchwork/models.py index 56daea1..f8d2472 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -350,10 +350,6 @@ class Submission(FilenameMixin, EmailMixin, models.Model): # patchwork metadata - def refresh_tag_counts(self): - # This is subclassed on 'Patch' to do something useful - pass - def is_editable(self, user): return False @@ -578,11 +574,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']
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 <markand@malikania.fr> Fixes: 86172ccc161b ("models: Split Patch into two models") Closes-bug: #111 ("A/R/T not updated on comments") Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> --- patchwork/models.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)