diff options
author | Dusty Phillips <buchuki@gmail.com> | 2008-10-07 16:41:28 -0400 |
---|---|---|
committer | Dusty Phillips <buchuki@gmail.com> | 2008-10-07 16:41:28 -0400 |
commit | 0d83b7add1aceeb604f2a1b204c8d731a7ef7a88 (patch) | |
tree | 93c1325328ffcde6a8a927adad7846c6a925b47a /packages/views.py | |
parent | 89b9cca358a7646fc5792751015c9894e6ec1e8d (diff) |
make sort form work
Diffstat (limited to 'packages/views.py')
-rw-r--r-- | packages/views.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/views.py b/packages/views.py index a42c9d12..544ab015 100644 --- a/packages/views.py +++ b/packages/views.py @@ -7,6 +7,7 @@ from django.shortcuts import get_object_or_404 from django.contrib.auth.models import User from django.contrib.admin.widgets import AdminDateWidget from django.views.generic import list_detail +from django.db.models import Q from datetime import datetime from archweb_dev.main.utils import render_response from archweb_dev.main.models import Package, PackageFile @@ -53,7 +54,7 @@ def details(request, pkgid=0, name='', repo='', arch=''): class PackageSearchForm(forms.Form): repo = forms.ChoiceField(required=False) arch = forms.ChoiceField(required=False) - keywords = forms.CharField(required=False) + q = forms.CharField(required=False) maintainer = forms.ChoiceField(required=False) last_update = forms.DateField(required=False, widget=AdminDateWidget()) limit = forms.ChoiceField( @@ -107,7 +108,14 @@ def search(request, page=None): packages = packages.filter( maintainer__username=form.cleaned_data['maintainer']) limit = form.cleaned_data['limit'] - + if form.cleaned_data['q']: + query = form.cleaned_data['q'] + q = Q(pkgname__icontains=query) | Q(pkgdesc__icontains=query) + packages = packages.filter(q) + if form.cleaned_data['last_update']: + lu = form.cleaned_data['last_update'] + packages = packages.filter(last_update_gte= + datetime.datetime(lu.year, lu.month, lu.day, 0, 0) else: form = PackageSearchForm() @@ -121,8 +129,6 @@ def search(request, page=None): template_object_name="package", extra_context=page_dict) - - # OLD IMPLEMENTATION BELOW HERE if request.GET.has_key('q'): # take the q GET var over the one passed on the URL |