aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinícius das Chagas Silva <vinimaster@gmail.com>2009-12-15 19:36:08 -0200
committerVinícius das Chagas Silva <vinimaster@gmail.com>2009-12-15 19:36:08 -0200
commit10913c3ee3d5406f0e5a130d7118005f2194f8f7 (patch)
tree4160c00eb970dfad7224d4dca1794dd01c50be17
parentb85ea9ce69936bb66f8e9b4f9c9746cb9b20ab85 (diff)
downloadchishop-10913c3ee3d5406f0e5a130d7118005f2194f8f7.tar.bz2
chishop-10913c3ee3d5406f0e5a130d7118005f2194f8f7.tar.xz
chishop-10913c3ee3d5406f0e5a130d7118005f2194f8f7.zip
Started search engine implementation - no totally integrated yet :(
-rw-r--r--djangopypi/forms.py3
-rw-r--r--djangopypi/urls.py5
-rw-r--r--djangopypi/views.py17
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
19class 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
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