summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/views.py14
-rw-r--r--templates/packages/search.html2
2 files changed, 11 insertions, 5 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
diff --git a/templates/packages/search.html b/templates/packages/search.html
index 54d04ef7..bf075584 100644
--- a/templates/packages/search.html
+++ b/templates/packages/search.html
@@ -23,7 +23,7 @@
<tr>
{% td_input search_form.arch %}
{% td_input search_form.repo %}
- {% td_input search_form.keywords %}
+ {% td_input search_form.q %}
{% td_input search_form.maintainer%}
{% td_input search_form.last_update %}
{% td_input search_form.limit %}