aboutsummaryrefslogtreecommitdiff
path: root/djangopypi/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'djangopypi/views.py')
-rw-r--r--djangopypi/views.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/djangopypi/views.py b/djangopypi/views.py
index 8817f66..03b92e5 100644
--- a/djangopypi/views.py
+++ b/djangopypi/views.py
@@ -15,12 +15,13 @@ from django.utils.datastructures import MultiValueDict
15from django.utils.translation import ugettext_lazy as _ 15from django.utils.translation import ugettext_lazy as _
16from django.core.files.uploadedfile import SimpleUploadedFile 16from django.core.files.uploadedfile import SimpleUploadedFile
17from django.contrib.auth import authenticate, login 17from django.contrib.auth import authenticate, login
18from django.db.models import Q
18 19
19from registration.backends import get_backend 20from registration.backends import get_backend
20from registration.forms import RegistrationForm 21from registration.forms import RegistrationForm
21 22
22from djangopypi.models import Project, Classifier, Release, UPLOAD_TO 23from djangopypi.models import Project, Classifier, Release, UPLOAD_TO
23from djangopypi.forms import ProjectForm, ReleaseForm 24from djangopypi.forms import ProjectForm, ReleaseForm, SearchForm
24from djangopypi.http import HttpResponseUnauthorized 25from djangopypi.http import HttpResponseUnauthorized
25from djangopypi.http import HttpResponseNotImplemented 26from djangopypi.http import HttpResponseNotImplemented
26from djangopypi.utils import decode_fs 27from djangopypi.utils import decode_fs
@@ -227,3 +228,17 @@ def show_version(request, dist_name, version,
227 }) 228 })
228 229
229 return render_to_response(template_name, context_instance=context) 230 return render_to_response(template_name, context_instance=context)
231
232def search(request):
233 if request.method == 'POST':
234 search_value = request.POST.get('search_value')
235 matches = Project.objects.get(Q(name__contains=search_value) | Q(description__contains=search_value))
236
237 return HttpResponse(matches)
238 else:
239 search_form = SearchForm()
240 return render_to_response(
241 "djangopypi/search.html",
242 {'search_form':search_form},
243 context_instance=RequestContext(request)
244 ) \ No newline at end of file