Mercurial > public > sg101
comparison gpp/forums/views/main.py @ 280:21d2ca3b4bf7
Fixing #121. The forum query pulldown should appear on all forum query pages for consistency.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 03 Oct 2010 20:44:09 +0000 |
parents | 307a74e28112 |
children | 8fd4984d5c3b |
comparison
equal
deleted
inserted
replaced
279:879d39647064 | 280:21d2ca3b4bf7 |
---|---|
12 from django.http import HttpResponseRedirect | 12 from django.http import HttpResponseRedirect |
13 from django.core.urlresolvers import reverse | 13 from django.core.urlresolvers import reverse |
14 from django.core.paginator import InvalidPage | 14 from django.core.paginator import InvalidPage |
15 from django.shortcuts import get_object_or_404 | 15 from django.shortcuts import get_object_or_404 |
16 from django.shortcuts import render_to_response | 16 from django.shortcuts import render_to_response |
17 from django.shortcuts import redirect | |
18 from django.template.loader import render_to_string | 17 from django.template.loader import render_to_string |
19 from django.template import RequestContext | 18 from django.template import RequestContext |
20 from django.views.decorators.http import require_POST | 19 from django.views.decorators.http import require_POST |
21 from django.utils.text import wrap | 20 from django.utils.text import wrap |
22 from django.db.models import F | 21 from django.db.models import F |
74 else: | 73 else: |
75 topic.page_range = None | 74 topic.page_range = None |
76 | 75 |
77 ####################################################################### | 76 ####################################################################### |
78 | 77 |
79 SPECIAL_QUERIES = { | |
80 'unread': 'forums-unread_topics', | |
81 'unanswered': 'forums-unanswered_topics', | |
82 'mine': 'forums-my_posts', | |
83 'favorites': 'forums-manage_favorites', | |
84 'subscriptions': 'forums-manage_subscriptions', | |
85 } | |
86 | |
87 def index(request): | 78 def index(request): |
88 """ | 79 """ |
89 This view displays all the forums available, ordered in each category. | 80 This view displays all the forums available, ordered in each category. |
90 """ | 81 """ |
91 # check for special forum queries | |
92 query = request.GET.get("query") | |
93 if query in SPECIAL_QUERIES: | |
94 return redirect(SPECIAL_QUERIES[query]) | |
95 | |
96 public_forums = Forum.objects.public_forums() | 82 public_forums = Forum.objects.public_forums() |
97 feeds = [{'name': 'All Forums', 'feed': FEED_BASE}] | 83 feeds = [{'name': 'All Forums', 'feed': FEED_BASE}] |
98 | 84 |
99 forums = Forum.objects.forums_for_user(request.user) | 85 forums = Forum.objects.forums_for_user(request.user) |
100 get_forum_unread_status(forums, request.user) | 86 get_forum_unread_status(forums, request.user) |