diff options
Diffstat (limited to 'djangopypi/views.py')
-rw-r--r-- | djangopypi/views.py | 17 |
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 | |||
15 | from django.utils.translation import ugettext_lazy as _ | 15 | from django.utils.translation import ugettext_lazy as _ |
16 | from django.core.files.uploadedfile import SimpleUploadedFile | 16 | from django.core.files.uploadedfile import SimpleUploadedFile |
17 | from django.contrib.auth import authenticate, login | 17 | from django.contrib.auth import authenticate, login |
18 | from django.db.models import Q | ||
18 | 19 | ||
19 | from registration.backends import get_backend | 20 | from registration.backends import get_backend |
20 | from registration.forms import RegistrationForm | 21 | from registration.forms import RegistrationForm |
21 | 22 | ||
22 | from djangopypi.models import Project, Classifier, Release, UPLOAD_TO | 23 | from djangopypi.models import Project, Classifier, Release, UPLOAD_TO |
23 | from djangopypi.forms import ProjectForm, ReleaseForm | 24 | from djangopypi.forms import ProjectForm, ReleaseForm, SearchForm |
24 | from djangopypi.http import HttpResponseUnauthorized | 25 | from djangopypi.http import HttpResponseUnauthorized |
25 | from djangopypi.http import HttpResponseNotImplemented | 26 | from djangopypi.http import HttpResponseNotImplemented |
26 | from djangopypi.utils import decode_fs | 27 | from 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 | |||
232 | def 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 | ||