diff options
Diffstat (limited to 'djangopypi/views.py')
-rw-r--r-- | djangopypi/views.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/djangopypi/views.py b/djangopypi/views.py index 952b269..9c78fcf 100644 --- a/djangopypi/views.py +++ b/djangopypi/views.py | |||
@@ -15,6 +15,7 @@ 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 |
@@ -227,3 +228,29 @@ 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 | search_term = '' | ||
234 | if request.method == 'POST': | ||
235 | search_term = request.POST.get('search_term') | ||
236 | if search_term != '': | ||
237 | dists = Project.objects.filter(Q(name__contains=search_term) | Q(summary__contains=search_term)) | ||
238 | return render_to_response( | ||
239 | 'djangopypi/search_results.html', | ||
240 | {'dists':dists,'search_term':search_term}, | ||
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_term':search_term}, | ||
248 | context_instance = RequestContext(request) | ||
249 | ) | ||
250 | else: | ||
251 | dists = Project.objects.all() | ||
252 | return render_to_response( | ||
253 | 'djangopypi/search_results.html', | ||
254 | {'search_term':search_term}, | ||
255 | context_instance = RequestContext(request) | ||
256 | ) \ No newline at end of file | ||