[extensions-web] Order alphabetically correctly with no explicit order
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Order alphabetically correctly with no explicit order
- Date: Sun, 18 Dec 2011 00:51:04 +0000 (UTC)
commit cd34fc5a42ef8dccf1fca2dfc1bd0e1bdb618344
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sat Dec 17 02:03:07 2011 -0500
Order alphabetically correctly with no explicit order
sweettooth/extensions/views.py | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index 0dfc817..1506401 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -100,8 +100,12 @@ def ajax_query_params_query(request):
if sort not in ('created', 'downloads', 'popularity', 'name'):
raise Http404()
- order = request.GET.get('order')
- order = dict(desc='-', asc='').get(order, '-')
+ if 'order' in request.GET:
+ order = request.GET['order']
+ order = dict(desc='-', asc='').get(order, '-')
+ else:
+ # order by ASC for 'name', DESC for everything else
+ order = dict(name='').get(sort, '-')
queryset = queryset.order_by('%s%s' % (order, sort))
return queryset
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]