diff options
author | Dan McGee <dan@archlinux.org> | 2011-10-12 08:54:51 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-10-12 08:54:51 -0500 |
commit | 21a8fec980eb0613d3cce8aae7d6bfe6680c038a (patch) | |
tree | c159263aa3d3682375ced4b396eb6a774951be25 | |
parent | 0d693fa1fb788a61359415f56dc487f4aa504a55 (diff) |
Package search and sort code cleanup
Move initializations closer to where they are actually needed, and
remove the sorting on multiple columns when a sort field is passed in.
We don't do this for the default sort, so let's not do it here either.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | packages/views.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/packages/views.py b/packages/views.py index a740e689..dab06919 100644 --- a/packages/views.py +++ b/packages/views.py @@ -293,24 +293,22 @@ def search(request, page=None): else: form = PackageSearchForm() - current_query = request.GET.urlencode() - page_dict = { - 'search_form': form, - 'current_query': current_query - } allowed_sort = ["arch", "repo", "pkgname", "pkgbase", "compressed_size", "installed_size", "build_date", "last_update", "flag_date"] allowed_sort += ["-" + s for s in allowed_sort] sort = request.GET.get('sort', None) - # TODO: sorting by multiple fields makes using a DB index much harder if sort in allowed_sort: - packages = packages.order_by( - request.GET['sort'], 'repo', 'arch', 'pkgname') + packages = packages.order_by(sort) page_dict['sort'] = sort else: packages = packages.order_by('pkgname') + current_query = request.GET.urlencode() + page_dict = { + 'search_form': form, + 'current_query': current_query + } return list_detail.object_list(request, packages, template_name="packages/search.html", page=page, |