[extensions-web] Move the new sorting/filtering code somewhere more appropriate
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Move the new sorting/filtering code somewhere more appropriate
- Date: Sun, 18 Dec 2011 00:50:59 +0000 (UTC)
commit 0fe7d50d203ee4432c6fab888e56b7a7f834a7fa
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sat Dec 17 02:01:36 2011 -0500
Move the new sorting/filtering code somewhere more appropriate
Just a minor code cleanup
sweettooth/extensions/views.py | 52 ++++++++++++++++++++--------------------
1 files changed, 26 insertions(+), 26 deletions(-)
---
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index ce3611c..0dfc817 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -39,32 +39,6 @@ def shell_download(request, uuid):
return redirect(version.source.url)
-def ajax_query_params_query(request):
- query_params = {}
-
- versions = request.GET.getlist('shell_version')
- if versions:
- versions = [models.ShellVersion.objects.lookup_for_version_string(v) for v in versions]
- versions = [v for v in versions if v is not None]
- query_params['versions__shell_versions__in'] = versions
-
- uuids = request.GET.getlist('uuid')
- if uuids:
- query_params['uuid__in'] = uuids
-
- queryset = models.Extension.objects.filter(**query_params)
-
- sort = request.GET.get('sort', 'name')
- sort = dict(recent='created').get(sort, sort)
- if sort not in ('created', 'downloads', 'popularity', 'name'):
- raise Http404()
-
- order = request.GET.get('order')
- order = dict(desc='-', asc='').get(order, '-')
-
- queryset = queryset.order_by('%s%s' % (order, sort))
- return queryset
-
@ajax_view
@require_POST
def shell_update(request):
@@ -106,6 +80,32 @@ def shell_update(request):
return operations
+def ajax_query_params_query(request):
+ query_params = {}
+
+ versions = request.GET.getlist('shell_version')
+ if versions:
+ versions = [models.ShellVersion.objects.lookup_for_version_string(v) for v in versions]
+ versions = [v for v in versions if v is not None]
+ query_params['versions__shell_versions__in'] = versions
+
+ uuids = request.GET.getlist('uuid')
+ if uuids:
+ query_params['uuid__in'] = uuids
+
+ queryset = models.Extension.objects.filter(**query_params)
+
+ sort = request.GET.get('sort', 'name')
+ sort = dict(recent='created').get(sort, sort)
+ if sort not in ('created', 'downloads', 'popularity', 'name'):
+ raise Http404()
+
+ order = request.GET.get('order')
+ order = dict(desc='-', asc='').get(order, '-')
+
+ queryset = queryset.order_by('%s%s' % (order, sort))
+ return queryset
+
@ajax_view
def ajax_extensions_list(request):
queryset = ajax_query_params_query(request)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]