changeset 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 879d39647064
children d9e01b36b761
files gpp/forums/views/main.py gpp/templates/forums/forum_query.html gpp/templates/forums/forum_query.js gpp/templates/forums/index.html gpp/templates/forums/manage_topics.html gpp/templates/forums/post_list.html gpp/templates/forums/topic_list.html
diffstat 7 files changed, 35 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/gpp/forums/views/main.py	Sun Oct 03 00:28:23 2010 +0000
+++ b/gpp/forums/views/main.py	Sun Oct 03 20:44:09 2010 +0000
@@ -14,7 +14,6 @@
 from django.core.paginator import InvalidPage
 from django.shortcuts import get_object_or_404
 from django.shortcuts import render_to_response
-from django.shortcuts import redirect
 from django.template.loader import render_to_string
 from django.template import RequestContext
 from django.views.decorators.http import require_POST
@@ -76,23 +75,10 @@
 
 #######################################################################
 
-SPECIAL_QUERIES = {
-    'unread': 'forums-unread_topics',
-    'unanswered': 'forums-unanswered_topics',
-    'mine': 'forums-my_posts',
-    'favorites': 'forums-manage_favorites',
-    'subscriptions': 'forums-manage_subscriptions',
-}
-
 def index(request):
     """
     This view displays all the forums available, ordered in each category.
     """
-    # check for special forum queries
-    query = request.GET.get("query")
-    if query in SPECIAL_QUERIES:
-        return redirect(SPECIAL_QUERIES[query])
-
     public_forums = Forum.objects.public_forums()
     feeds = [{'name': 'All Forums', 'feed': FEED_BASE}]
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/templates/forums/forum_query.html	Sun Oct 03 20:44:09 2010 +0000
@@ -0,0 +1,12 @@
+<form action="." method="get" id="forum-query-form">
+   <select id="forum-query-select">
+      <option value="{% url forums-unread_topics %}">Show topics with unread posts</option>
+      <option value="{% url forums-unanswered_topics %}">Show unanswered posts</option>
+      {% if user.is_authenticated %}
+      <option value="{% url forums-my_posts %}">Show my posts</option>
+      <option value="{% url forums-manage_favorites %}">Show my favorite topics</option>
+      <option value="{% url forums-manage_subscriptions %}">Show my subscribed topics</option>
+      {% endif %}
+   </select>
+   <button type="button" id="forum-query-button">Go</button>
+</form>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/templates/forums/forum_query.js	Sun Oct 03 20:44:09 2010 +0000
@@ -0,0 +1,11 @@
+<script type="text/javascript">
+//<![CDATA[
+   $(document).ready(function() {
+      var navSelect = $('#forum-query-select')[0];
+      $('#forum-query-button').click(function() {
+         var dest = navSelect.options[navSelect.selectedIndex].value;
+         window.location = dest;
+      });
+   });
+//]]>
+</script>
--- a/gpp/templates/forums/index.html	Sun Oct 03 00:28:23 2010 +0000
+++ b/gpp/templates/forums/index.html	Sun Oct 03 20:44:09 2010 +0000
@@ -6,20 +6,13 @@
 {% for feed in feeds %}
 <link rel="alternate" type="application/rss+xml" title="{{ feed.name }}" href="{{ feed.feed }}" />
 {% endfor %}
+{% include "forums/forum_query.js" %}
 {% endblock %}
 {% block title %}Forums{% endblock %}
 {% block content %}
 <h2>Forums <a href="/feeds/forums/"><img src="{{ MEDIA_URL }}icons/feed.png" alt="Forums Feed" title="Forums Feed" /></a></h2>
 
-<form action="." method="get" id="forum-query-form">
-   <select name="query">
-      <option value="unread">Show topics with unread posts</option>
-      <option value="mine">Show my posts</option>
-      <option value="unanswered">Show unanswered posts</option>
-      <option value="favorites">Show my favorite topics</option>
-      <option value="subscriptions">Show my subscribed topics</option>
-   </select><input type="submit" value="Go" />
-</form>
+{% include "forums/forum_query.html" %}
 
 <div class="forum-block">
 {% for iter in cats %}
--- a/gpp/templates/forums/manage_topics.html	Sun Oct 03 00:28:23 2010 +0000
+++ b/gpp/templates/forums/manage_topics.html	Sun Oct 03 20:44:09 2010 +0000
@@ -24,6 +24,7 @@
 });
 //]]>
 </script>
+{% include "forums/forum_query.js" %}
 {% endblock %}
 {% block content %}
 <h2>Forums: {{ page_title }}</h2>
@@ -31,6 +32,7 @@
 <h3>
    <a href="{% url forums-index %}">SurfGuitar101 Forum Index</a> &raquo; {{ page_title }}
 </h3>
+{% include "forums/forum_query.html" %}
 <p>{{ description }}</p>
 {% include 'forums/pagination.html' %}
 <form id="topic_form" action="." method="post">{% csrf_token %}
--- a/gpp/templates/forums/post_list.html	Sun Oct 03 00:28:23 2010 +0000
+++ b/gpp/templates/forums/post_list.html	Sun Oct 03 20:44:09 2010 +0000
@@ -1,11 +1,15 @@
 {% extends 'base.html' %}
 {% load forum_tags %}
 {% block title %}Forums: {{ title }}{% endblock %}
+{% block custom_js %}
+{% include "forums/forum_query.js" %}
+{% endblock %}
 {% block content %}
 <h2>Forums: {{ title }}</h2>
 <h3>
 <a href="{% url forums-index %}">SurfGuitar101 Forum Index</a> &raquo; {{ title }}
 </h3>
+{% include "forums/forum_query.html" %}
 <div class="forum-block">
 {{ page_nav }}
 {% if page.object_list %}
--- a/gpp/templates/forums/topic_list.html	Sun Oct 03 00:28:23 2010 +0000
+++ b/gpp/templates/forums/topic_list.html	Sun Oct 03 20:44:09 2010 +0000
@@ -1,11 +1,15 @@
 {% extends 'base.html' %}
 {% load forum_tags %}
 {% block title %}Forums: {{ title }}{% endblock %}
+{% block custom_js %}
+{% include "forums/forum_query.js" %}
+{% endblock %}
 {% block content %}
 <h2>Forums: {{ title }}</h2>
 <h3>
 <a href="{% url forums-index %}">SurfGuitar101 Forum Index</a> &raquo; {{ title }}
 </h3>
+{% include "forums/forum_query.html" %}
 <div class="forum-block">
 {{ page_nav }}
 <table class="forum-topic-table">