comparison gpp/forums/views.py @ 181:500e5875a306

Implementing #61: adding a forum topic subscription feature.
author Brian Neal <bgneal@gmail.com>
date Sun, 28 Mar 2010 01:07:47 +0000
parents 0fa78ef80356
children db202792d9f5
comparison
equal deleted inserted replaced
180:aef00df91165 181:500e5875a306
191 can_moderate = _can_moderate(topic.forum, request.user) 191 can_moderate = _can_moderate(topic.forum, request.user)
192 192
193 can_reply = request.user.is_authenticated() and ( 193 can_reply = request.user.is_authenticated() and (
194 not topic.locked or can_moderate) 194 not topic.locked or can_moderate)
195 195
196 is_subscribed = request.user.is_authenticated() and (
197 topic in request.user.subscriptions.all())
198
196 return render_to_response('forums/topic.html', { 199 return render_to_response('forums/topic.html', {
197 'forum': topic.forum, 200 'forum': topic.forum,
198 'topic': topic, 201 'topic': topic,
199 'page': page, 202 'page': page,
200 'page_nav': page_nav, 203 'page_nav': page_nav,
201 'last_page': last_page, 204 'last_page': last_page,
202 'can_moderate': can_moderate, 205 'can_moderate': can_moderate,
203 'can_reply': can_reply, 206 'can_reply': can_reply,
204 'form': NewPostForm(initial={'topic_id': topic.id}), 207 'form': NewPostForm(initial={'topic_id': topic.id}),
208 'is_subscribed': is_subscribed,
205 }, 209 },
206 context_instance=RequestContext(request)) 210 context_instance=RequestContext(request))
207 211
208 212
209 @login_required 213 @login_required
432 post counts as that doesn't seem to be worth the effort. 436 post counts as that doesn't seem to be worth the effort.
433 """ 437 """
434 if topic.forum.last_post and topic.forum.last_post.topic == topic: 438 if topic.forum.last_post and topic.forum.last_post.topic == topic:
435 topic.forum.last_post_pre_delete() 439 topic.forum.last_post_pre_delete()
436 topic.forum.save() 440 topic.forum.save()
441
442 # delete subscriptions to this topic
443 topic.subscribers.clear()
437 444
438 # It should be safe to just delete the topic now. This will 445 # It should be safe to just delete the topic now. This will
439 # automatically delete all posts in the topic. 446 # automatically delete all posts in the topic.
440 topic.delete() 447 topic.delete()
441 448