fix #80: incorrect post count after deleting from admin panel
This commit is contained in:
parent
ddd336f51e
commit
51fbbcd5a4
2 changed files with 4 additions and 3 deletions
|
@ -199,11 +199,13 @@ class Post(models.Model):
|
|||
self.body_html = smiles(self.body_html)
|
||||
super(Post, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
self_id = self.id
|
||||
head_post_id = self.topic.posts.order_by('created')[0].id
|
||||
forum = self.topic.forum
|
||||
topic = self.topic
|
||||
profile = self.user.forum_profile
|
||||
self.last_topic_post.clear()
|
||||
self.last_forum_post.clear()
|
||||
super(Post, self).delete(*args, **kwargs)
|
||||
|
@ -224,6 +226,8 @@ class Post(models.Model):
|
|||
forum.post_count = Post.objects.filter(topic__forum=forum).count()
|
||||
forum.topic_count = Topic.objects.filter(forum=forum).count()
|
||||
forum.save()
|
||||
profile.post_count = Post.objects.filter(user=self.user).count()
|
||||
profile.save()
|
||||
|
||||
@models.permalink
|
||||
def get_absolute_url(self):
|
||||
|
|
|
@ -674,9 +674,6 @@ def delete_post(request, post_id):
|
|||
return HttpResponseRedirect(post.get_absolute_url())
|
||||
|
||||
post.delete()
|
||||
profile = post.user.forum_profile
|
||||
profile.post_count = Post.objects.filter(user=post.user).count()
|
||||
profile.save()
|
||||
|
||||
try:
|
||||
Topic.objects.get(pk=topic.id)
|
||||
|
|
Reference in a new issue