Mercurial > public > sg101
diff gpp/forums/views.py @ 82:bc3978f023c2
Forums: started the ability to display topics inside a forum.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 23 Aug 2009 04:04:29 +0000 |
parents | e356ea79a7a2 |
children | 5b4c812b448e |
line wrap: on
line diff
--- a/gpp/forums/views.py Sun Aug 23 00:14:52 2009 +0000 +++ b/gpp/forums/views.py Sun Aug 23 04:04:29 2009 +0000 @@ -1,6 +1,8 @@ """ Views for the forums application. """ +from django.http import Http404 +from django.shortcuts import get_object_or_404 from django.shortcuts import render_to_response from django.template import RequestContext @@ -8,6 +10,9 @@ def index(request): + """ + This view displays all the forums available, ordered in each category. + """ forums = Forum.objects.all().select_related() cats = {} for forum in forums: @@ -25,5 +30,23 @@ }, context_instance=RequestContext(request)) + def forum_index(request, slug): - pass + """ + Displays all the topics in a forum. + """ + forum = get_object_or_404(Forum, slug=slug) + topics = forum.topics.select_related() + + return render_to_response('forums/forum_index.html', { + 'forum': forum, + 'topics': topics, + }, + context_instance=RequestContext(request)) + + +def topic_index(request, id): + """ + Displays all the posts in a topic. + """ + raise Http404