Mercurial > public > sg101
diff gpp/forums/views.py @ 86:f81226b5e87b
Forums: Some display work for the posts within a topic. Sketched out a post reply form.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 20:47:08 +0000 |
parents | 5b4c812b448e |
children | 515d1daec811 |
line wrap: on
line diff
--- a/gpp/forums/views.py Sun Aug 30 19:58:42 2009 +0000 +++ b/gpp/forums/views.py Sat Sep 05 20:47:08 2009 +0000 @@ -12,6 +12,7 @@ from forums.models import Forum from forums.models import Topic from forums.forms import NewTopicForm +from forums.forms import PostForm def index(request): @@ -54,7 +55,19 @@ """ Displays all the posts in a topic. """ - raise Http404 + topic = get_object_or_404(Topic, pk=id) + topic.view_count += 1 + topic.save() + + posts = topic.posts.select_related() + + return render_to_response('forums/topic.html', { + 'forum': topic.forum, + 'topic': topic, + 'posts': posts, + 'form': PostForm(), + }, + context_instance=RequestContext(request)) @login_required