summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/templatetags/package_extras.py16
-rw-r--r--packages/views.py10
2 files changed, 14 insertions, 12 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py
index d59a5562..24264af0 100644
--- a/packages/templatetags/package_extras.py
+++ b/packages/templatetags/package_extras.py
@@ -1,4 +1,6 @@
-import cgi, urllib
+import urllib
+import urlparse
+
from django import template
from django.utils.html import escape
@@ -9,15 +11,15 @@ class BuildQueryStringNode(template.Node):
self.sortfield = sortfield
def render(self, context):
- qs = dict(cgi.parse_qsl(context['current_query'][1:]))
- if qs.has_key('sort') and qs['sort'] == self.sortfield:
+ qs = urlparse.parse_qs(context['current_query'])
+ if qs.has_key('sort') and self.sortfield in qs['sort']:
if self.sortfield.startswith('-'):
- qs['sort'] = self.sortfield[1:]
+ qs['sort'] = [self.sortfield[1:]]
else:
- qs['sort'] = '-' + self.sortfield
+ qs['sort'] = ['-' + self.sortfield]
else:
- qs['sort'] = self.sortfield
- return '?' + urllib.urlencode(qs)
+ qs['sort'] = [self.sortfield]
+ return urllib.urlencode(qs, True)
@register.tag(name='buildsortqs')
def do_buildsortqs(parser, token):
diff --git a/packages/views.py b/packages/views.py
index 59779fe4..3cef8226 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -168,12 +168,10 @@ class PackageSearchForm(forms.Form):
[(m.username, m.get_full_name()) for m in maints]
def search(request, page=None):
- current_query = '?'
limit = 50
packages = Package.objects.select_related('arch', 'repo')
if request.GET:
- current_query += request.GET.urlencode()
form = PackageSearchForm(data=request.GET)
if form.is_valid():
if form.cleaned_data['repo']:
@@ -208,12 +206,14 @@ def search(request, page=None):
else:
form = PackageSearchForm()
- page_dict = {'search_form': form,
- 'current_query': current_query
- }
if packages.count() == 1:
return redirect(packages[0])
+ current_query = request.GET.urlencode()
+ page_dict = {
+ 'search_form': form,
+ 'current_query': current_query
+ }
allowed_sort = ["arch", "repo", "pkgname", "last_update", "flag_date"]
allowed_sort += ["-" + s for s in allowed_sort]
sort = request.GET.get('sort', None)