summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/urls.py1
-rw-r--r--packages/utils.py2
-rw-r--r--packages/views/display.py2
-rw-r--r--packages/views/search.py42
4 files changed, 7 insertions, 40 deletions
diff --git a/packages/urls.py b/packages/urls.py
index 9a151b4..4e2e263 100644
--- a/packages/urls.py
+++ b/packages/urls.py
@@ -24,7 +24,6 @@ urlpatterns = patterns('packages.views',
(r'^update/$', 'update'),
(r'^$', SearchListView.as_view(), {}, 'packages-search'),
- (r'^(?P<page>\d+)/$', SearchListView.as_view()),
(r'^search/json/$', 'search_json'),
(r'^differences/$', 'arch_differences', {}, 'packages-differences'),
diff --git a/packages/utils.py b/packages/utils.py
index 49aeb8c..ef6311e 100644
--- a/packages/utils.py
+++ b/packages/utils.py
@@ -79,7 +79,7 @@ def get_split_packages_info():
pkgnames = Package.objects.values('pkgname')
split_pkgs = Package.objects.exclude(pkgname=F('pkgbase')).exclude(
pkgbase__in=pkgnames).values('pkgbase', 'repo', 'arch').annotate(
- last_update=Max('last_update'))
+ last_update=Max('last_update')).order_by().distinct()
all_arches = Arch.objects.in_bulk({s['arch'] for s in split_pkgs})
all_repos = Repo.objects.in_bulk({s['repo'] for s in split_pkgs})
for split in split_pkgs:
diff --git a/packages/views/display.py b/packages/views/display.py
index 497c8d4..fcf8fde 100644
--- a/packages/views/display.py
+++ b/packages/views/display.py
@@ -104,6 +104,8 @@ def redirect_agnostic(request, name, repo, arch):
def redirect_to_search(request, name, repo, arch):
+ if request.GET.get('q'):
+ name = request.GET.get('q')
pkg_data = [
('arch', arch.lower()),
('repo', repo.lower()),
diff --git a/packages/views/search.py b/packages/views/search.py
index 9cb5f38..0362602 100644
--- a/packages/views/search.py
+++ b/packages/views/search.py
@@ -1,6 +1,4 @@
-from datetime import datetime
import json
-from pytz import utc
from django import forms
from django.contrib.auth.models import User
@@ -14,26 +12,6 @@ from ..models import PackageRelation
from ..utils import attach_maintainers, PackageJSONEncoder
-def coerce_limit_value(value):
- if not value:
- return None
- if value == 'all':
- # negative value indicates show all results
- return -1
- value = int(value)
- if value < 0:
- raise ValueError
- return value
-
-class LimitTypedChoiceField(forms.TypedChoiceField):
- def valid_value(self, value):
- try:
- coerce_limit_value(value)
- return True
- except (ValueError, TypeError):
- return False
-
-
class PackageSearchForm(forms.Form):
repo = forms.MultipleChoiceField(required=False)
arch = forms.MultipleChoiceField(required=False)
@@ -46,11 +24,6 @@ class PackageSearchForm(forms.Form):
flagged = forms.ChoiceField(
choices=[('', 'All')] + make_choice(['Flagged', 'Not Flagged']),
required=False)
- limit = LimitTypedChoiceField(
- choices=make_choice([50, 100, 250]) + [('all', 'All')],
- coerce=coerce_limit_value,
- required=False,
- initial=50)
def __init__(self, *args, **kwargs):
show_staging = kwargs.pop('show_staging', False)
@@ -119,6 +92,7 @@ def parse_form(form, packages):
class SearchListView(ListView):
template_name = "packages/search.html"
+ paginate_by = 100
sort_fields = ("arch", "repo", "pkgname", "pkgbase", "compressed_size",
"installed_size", "build_date", "last_update", "flag_date")
@@ -145,19 +119,11 @@ class SearchListView(ListView):
# Form had errors so don't return any results
return Package.objects.none()
- def get_paginate_by(self, queryset):
- limit = 50
- if self.form.is_valid():
- asked_limit = self.form.cleaned_data['limit']
- if asked_limit and asked_limit < 0:
- limit = None
- elif asked_limit:
- limit = asked_limit
- return limit
-
def get_context_data(self, **kwargs):
context = super(SearchListView, self).get_context_data(**kwargs)
- context['current_query'] = self.request.GET.urlencode()
+ query_params = self.request.GET.copy()
+ query_params.pop('page', None)
+ context['current_query'] = query_params.urlencode()
context['search_form'] = self.form
return context