Mercurial > public > sg101
diff 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 |
line wrap: on
line diff
--- a/gpp/forums/views.py Sun Mar 21 20:33:33 2010 +0000 +++ b/gpp/forums/views.py Sun Mar 28 01:07:47 2010 +0000 @@ -193,6 +193,9 @@ can_reply = request.user.is_authenticated() and ( not topic.locked or can_moderate) + is_subscribed = request.user.is_authenticated() and ( + topic in request.user.subscriptions.all()) + return render_to_response('forums/topic.html', { 'forum': topic.forum, 'topic': topic, @@ -202,6 +205,7 @@ 'can_moderate': can_moderate, 'can_reply': can_reply, 'form': NewPostForm(initial={'topic_id': topic.id}), + 'is_subscribed': is_subscribed, }, context_instance=RequestContext(request)) @@ -435,6 +439,9 @@ topic.forum.last_post_pre_delete() topic.forum.save() + # delete subscriptions to this topic + topic.subscribers.clear() + # It should be safe to just delete the topic now. This will # automatically delete all posts in the topic. topic.delete()