diff options
Diffstat (limited to 'djangopypi/views.py')
-rw-r--r-- | djangopypi/views.py | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/djangopypi/views.py b/djangopypi/views.py index 03b92e5..0ac6dbc 100644 --- a/djangopypi/views.py +++ b/djangopypi/views.py | |||
@@ -21,7 +21,7 @@ from registration.backends import get_backend | |||
21 | from registration.forms import RegistrationForm | 21 | from registration.forms import RegistrationForm |
22 | 22 | ||
23 | from djangopypi.models import Project, Classifier, Release, UPLOAD_TO | 23 | from djangopypi.models import Project, Classifier, Release, UPLOAD_TO |
24 | from djangopypi.forms import ProjectForm, ReleaseForm, SearchForm | 24 | from djangopypi.forms import ProjectForm, ReleaseForm |
25 | from djangopypi.http import HttpResponseUnauthorized | 25 | from djangopypi.http import HttpResponseUnauthorized |
26 | from djangopypi.http import HttpResponseNotImplemented | 26 | from djangopypi.http import HttpResponseNotImplemented |
27 | from djangopypi.utils import decode_fs | 27 | from djangopypi.utils import decode_fs |
@@ -230,15 +230,27 @@ def show_version(request, dist_name, version, | |||
230 | return render_to_response(template_name, context_instance=context) | 230 | return render_to_response(template_name, context_instance=context) |
231 | 231 | ||
232 | def search(request): | 232 | def search(request): |
233 | search_value = '' | ||
233 | if request.method == 'POST': | 234 | if request.method == 'POST': |
234 | search_value = request.POST.get('search_value') | 235 | search_value = request.POST.get('search_value') |
235 | matches = Project.objects.get(Q(name__contains=search_value) | Q(description__contains=search_value)) | 236 | if search_value != '': |
236 | 237 | dists = Project.objects.filter(Q(name__contains=search_value) | Q(summary__contains=search_value)) | |
237 | return HttpResponse(matches) | 238 | return render_to_response( |
239 | 'djangopypi/search_results.html', | ||
240 | {'dists':dists,'search_value':search_value}, | ||
241 | context_instance = RequestContext(request) | ||
242 | ) | ||
243 | else: | ||
244 | dists = Project.objects.all() | ||
245 | return render_to_response( | ||
246 | 'djangopypi/search_results.html', | ||
247 | {'search_value':search_value}, | ||
248 | context_instance = RequestContext(request) | ||
249 | ) | ||
238 | else: | 250 | else: |
239 | search_form = SearchForm() | 251 | dists = Project.objects.all() |
240 | return render_to_response( | 252 | return render_to_response( |
241 | "djangopypi/search.html", | 253 | 'djangopypi/search_results.html', |
242 | {'search_form':search_form}, | 254 | {'search_value':search_value}, |
243 | context_instance=RequestContext(request) | 255 | context_instance = RequestContext(request) |
244 | ) \ No newline at end of file | 256 | ) \ No newline at end of file |