comparison gpp/forums/views/main.py @ 263:307a74e28112

Fixing #113; re-arrange the RSS forum feed icons around a bit.
author Brian Neal <bgneal@gmail.com>
date Thu, 23 Sep 2010 00:26:07 +0000
parents d302c498560e
children 21d2ca3b4bf7
comparison
equal deleted inserted replaced
262:5232d5808057 263:307a74e28112
36 36
37 ####################################################################### 37 #######################################################################
38 38
39 TOPICS_PER_PAGE = 50 39 TOPICS_PER_PAGE = 50
40 POSTS_PER_PAGE = 20 40 POSTS_PER_PAGE = 20
41 FEED_BASE = '/feeds/forums/'
42 FORUM_FEED = FEED_BASE + '%s/'
41 43
42 44
43 def get_page_num(request): 45 def get_page_num(request):
44 """Returns the value of the 'page' variable in GET if it exists, or 1 46 """Returns the value of the 'page' variable in GET if it exists, or 1
45 if it does not.""" 47 if it does not."""
90 query = request.GET.get("query") 92 query = request.GET.get("query")
91 if query in SPECIAL_QUERIES: 93 if query in SPECIAL_QUERIES:
92 return redirect(SPECIAL_QUERIES[query]) 94 return redirect(SPECIAL_QUERIES[query])
93 95
94 public_forums = Forum.objects.public_forums() 96 public_forums = Forum.objects.public_forums()
95 feeds = [{'name': 'All Forums', 'feed': '/feeds/forums/'}] 97 feeds = [{'name': 'All Forums', 'feed': FEED_BASE}]
96 98
97 forums = Forum.objects.forums_for_user(request.user) 99 forums = Forum.objects.forums_for_user(request.user)
98 get_forum_unread_status(forums, request.user) 100 get_forum_unread_status(forums, request.user)
99 cats = {} 101 cats = {}
100 for forum in forums: 102 for forum in forums:
101 forum.has_feed = forum in public_forums 103 forum.has_feed = forum in public_forums
102 if forum.has_feed: 104 if forum.has_feed:
103 feeds.append({ 105 feeds.append({
104 'name': '%s Forum' % forum.name, 106 'name': '%s Forum' % forum.name,
105 'feed': '/feeds/forums/%s/' % forum.slug, 107 'feed': FORUM_FEED % forum.slug,
106 }) 108 })
107 109
108 cat = cats.setdefault(forum.category.id, { 110 cat = cats.setdefault(forum.category.id, {
109 'cat': forum.category, 111 'cat': forum.category,
110 'forums': [], 112 'forums': [],
127 """ 129 """
128 forum = get_object_or_404(Forum.objects.select_related(), slug=slug) 130 forum = get_object_or_404(Forum.objects.select_related(), slug=slug)
129 131
130 if not forum.category.can_access(request.user): 132 if not forum.category.can_access(request.user):
131 return HttpResponseForbidden() 133 return HttpResponseForbidden()
134
135 feed = None
136 if not forum.category.groups.all():
137 feed = {
138 'name': '%s Forum' % forum.name,
139 'feed': FORUM_FEED % forum.slug,
140 }
132 141
133 topics = forum.topics.select_related('user', 'last_post', 'last_post__user') 142 topics = forum.topics.select_related('user', 'last_post', 'last_post__user')
134 get_topic_unread_status(forum, topics, request.user) 143 get_topic_unread_status(forum, topics, request.user)
135 144
136 paginator = create_topic_paginator(topics) 145 paginator = create_topic_paginator(topics)
147 156
148 can_moderate = _can_moderate(forum, request.user) 157 can_moderate = _can_moderate(forum, request.user)
149 158
150 return render_to_response('forums/forum_index.html', { 159 return render_to_response('forums/forum_index.html', {
151 'forum': forum, 160 'forum': forum,
161 'feed': feed,
152 'page': page, 162 'page': page,
153 'page_nav': page_nav, 163 'page_nav': page_nav,
154 'can_moderate': can_moderate, 164 'can_moderate': can_moderate,
155 }, 165 },
156 context_instance=RequestContext(request)) 166 context_instance=RequestContext(request))