comparison gpp/forums/views.py @ 189:db202792d9f5

Explicitly set session settings. Use the cache_db engine. Some minor tweaks to reduce some queries in forums.
author Brian Neal <bgneal@gmail.com>
date Thu, 01 Apr 2010 01:39:37 +0000
parents 500e5875a306
children 8c1832b9d815
comparison
equal deleted inserted replaced
188:d293b423bdaf 189:db202792d9f5
17 from django.shortcuts import redirect 17 from django.shortcuts import redirect
18 from django.template.loader import render_to_string 18 from django.template.loader import render_to_string
19 from django.template import RequestContext 19 from django.template import RequestContext
20 from django.views.decorators.http import require_POST 20 from django.views.decorators.http import require_POST
21 from django.utils.text import wrap 21 from django.utils.text import wrap
22 from django.db.models import F
22 23
23 from core.paginator import DiggPaginator 24 from core.paginator import DiggPaginator
24 from core.functions import email_admins 25 from core.functions import email_admins
25 from forums.models import Forum, Topic, Post, FlaggedPost, TopicLastVisit, \ 26 from forums.models import Forum, Topic, Post, FlaggedPost, TopicLastVisit, \
26 ForumLastVisit 27 ForumLastVisit
150 151
151 def topic_index(request, id): 152 def topic_index(request, id):
152 """ 153 """
153 Displays all the posts in a topic. 154 Displays all the posts in a topic.
154 """ 155 """
155 topic = get_object_or_404(Topic.objects.select_related(), pk=id) 156 topic = get_object_or_404(Topic.objects.select_related(
157 'forum', 'forum__category', 'last_post'), pk=id)
156 158
157 if not topic.forum.category.can_access(request.user): 159 if not topic.forum.category.can_access(request.user):
158 return HttpResponseForbidden() 160 return HttpResponseForbidden()
159 161
160 topic.view_count += 1 162 topic.view_count = F('view_count') + 1
161 topic.save() 163 topic.save(force_update=True)
162 164
163 posts = topic.posts.select_related() 165 posts = topic.posts.select_related()
164 166
165 paginator = create_post_paginator(posts) 167 paginator = create_post_paginator(posts)
166 page_num = get_page_num(request) 168 page_num = get_page_num(request)