diff options
author | VinÃcius das Chagas Silva <vinimaster@gmail.com> | 2009-12-15 19:36:08 -0200 |
---|---|---|
committer | VinÃcius das Chagas Silva <vinimaster@gmail.com> | 2009-12-15 19:36:08 -0200 |
commit | 10913c3ee3d5406f0e5a130d7118005f2194f8f7 (patch) | |
tree | 4160c00eb970dfad7224d4dca1794dd01c50be17 | |
parent | b85ea9ce69936bb66f8e9b4f9c9746cb9b20ab85 (diff) | |
download | chishop-10913c3ee3d5406f0e5a130d7118005f2194f8f7.tar.bz2 chishop-10913c3ee3d5406f0e5a130d7118005f2194f8f7.tar.xz chishop-10913c3ee3d5406f0e5a130d7118005f2194f8f7.zip |
Started search engine implementation - no totally integrated yet :(
-rw-r--r-- | djangopypi/forms.py | 3 | ||||
-rw-r--r-- | djangopypi/urls.py | 5 | ||||
-rw-r--r-- | djangopypi/views.py | 17 |
3 files changed, 22 insertions, 3 deletions
diff --git a/djangopypi/forms.py b/djangopypi/forms.py index 5484747..6587ef0 100644 --- a/djangopypi/forms.py +++ b/djangopypi/forms.py | |||
@@ -15,4 +15,7 @@ class ReleaseForm(forms.ModelForm): | |||
15 | class Meta: | 15 | class Meta: |
16 | model = Release | 16 | model = Release |
17 | exclude = ['project'] | 17 | exclude = ['project'] |
18 | |||
19 | class SearchForm(forms.Form): | ||
20 | search_value = forms.CharField(max_length=200) | ||
18 | 21 | ||
diff --git a/djangopypi/urls.py b/djangopypi/urls.py index d6cccb5..79b16be 100644 --- a/djangopypi/urls.py +++ b/djangopypi/urls.py | |||
@@ -19,5 +19,6 @@ urlpatterns = patterns("djangopypi.views", | |||
19 | url(r'^(?P<dist_name>[\w\d_\.\-]+)/$', "show_links", | 19 | url(r'^(?P<dist_name>[\w\d_\.\-]+)/$', "show_links", |
20 | {'template_name': 'djangopypi/pypi_show_links.html'}, | 20 | {'template_name': 'djangopypi/pypi_show_links.html'}, |
21 | name="djangopypi-pypi_show_links"), | 21 | name="djangopypi-pypi_show_links"), |
22 | ) | 22 | |
23 | 23 | url(r'^search','search',name='djangopypi-search') | |
24 | ) \ No newline at end of file | ||
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 | ||