Mercurial > public > sg101
comparison 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 |
comparison
equal
deleted
inserted
replaced
85:531fcc342a03 | 86:f81226b5e87b |
---|---|
10 from django.template import RequestContext | 10 from django.template import RequestContext |
11 | 11 |
12 from forums.models import Forum | 12 from forums.models import Forum |
13 from forums.models import Topic | 13 from forums.models import Topic |
14 from forums.forms import NewTopicForm | 14 from forums.forms import NewTopicForm |
15 from forums.forms import PostForm | |
15 | 16 |
16 | 17 |
17 def index(request): | 18 def index(request): |
18 """ | 19 """ |
19 This view displays all the forums available, ordered in each category. | 20 This view displays all the forums available, ordered in each category. |
52 | 53 |
53 def topic_index(request, id): | 54 def topic_index(request, id): |
54 """ | 55 """ |
55 Displays all the posts in a topic. | 56 Displays all the posts in a topic. |
56 """ | 57 """ |
57 raise Http404 | 58 topic = get_object_or_404(Topic, pk=id) |
59 topic.view_count += 1 | |
60 topic.save() | |
61 | |
62 posts = topic.posts.select_related() | |
63 | |
64 return render_to_response('forums/topic.html', { | |
65 'forum': topic.forum, | |
66 'topic': topic, | |
67 'posts': posts, | |
68 'form': PostForm(), | |
69 }, | |
70 context_instance=RequestContext(request)) | |
58 | 71 |
59 | 72 |
60 @login_required | 73 @login_required |
61 def new_topic(request, slug): | 74 def new_topic(request, slug): |
62 """ | 75 """ |