fix #80: incorrect post count after deleting from admin panel

This commit is contained in:
slav0nic 2010-02-17 12:41:01 +02:00
parent ddd336f51e
commit 51fbbcd5a4
2 changed files with 4 additions and 3 deletions

View file

@ -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):

View file

@ -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)