Changeset 153:29e8f38274e2 for apps/forum/models.py
- Timestamp:
- Oct 21, 2009 2:35:14 PM (4 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
apps/forum/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
apps/forum/models.py
r152 r153 217 217 def delete(self, *args, **kwargs): 218 218 self_id = self.id 219 head_post_id = self.topic.posts.latest().id 219 head_post_id = self.topic.posts.order_by('created')[0].id 220 forum = self.topic.forum 221 topic = self.topic 220 222 self.last_topic_post.clear() 221 223 self.last_forum_post.clear() 222 224 super(Post, self).delete(*args, **kwargs) 223 224 225 #if post was last in topic - remove topic 225 226 if self_id == head_post_id: 226 self.topic.delete() 227 topic.delete() 228 else: 229 try: 230 topic.last_post = Post.objects.filter(topic=topic).latest() 231 except Post.DoesNotExist: 232 topic.last_post = None 233 topic.post_count = Post.objects.filter(topic=topic).count() 234 topic.save() 235 try: 236 forum.last_post = Post.objects.filter(topic__forum=forum).latest() 237 except Post.DoesNotExist: 238 forum.last_post = None 239 forum.post_count = Post.objects.filter(topic__forum=forum).count() 240 forum.topic_count = Topic.objects.filter(forum=forum).count() 241 forum.save() 242 227 243 228 244
Note: See TracChangeset
for help on using the changeset viewer.
