Commit 2b9f9c05 authored by Okhin's avatar Okhin

Changing the default form

parent ebc98d8a
......@@ -38,14 +38,14 @@ class AddViolation(forms.Form):
captcha = CaptchaField(label=_("In order to protect against spam, please fill in the result of the following calculation. (note the + and the * are somewhat confusing)"))
class SearchViolation(SearchForm):
country = forms.ChoiceField(required=True, choices=(('',''),)+tuple(sorted(COUNTRIES,key=itemgetter(1))), label=_("Country"), help_text=_('EU member state where the restriction is reported.'))
operator = forms.CharField(required=True, max_length=256, label=_("Operator"), help_text=_('The ISP or operator providing the Internet service.'))
contract = forms.CharField(required=True, max_length=256, label=_("Contract"), help_text=_('The specific contract at the ISP provider. (please be as specific as possible)'))
media = forms.ChoiceField(required=True, choices=(('',''),)+tuple(sorted(MEDIA,key=itemgetter(1))), label=_('Is the Internet connection over mobile or fixed line?'))
country = forms.ChoiceField(required=False, choices=(('',''),)+tuple(sorted(COUNTRIES,key=itemgetter(1))), label=_("Country"), help_text=_('EU member state where the restriction is reported.'))
operator = forms.CharField(required=False, max_length=256, label=_("Operator"), help_text=_('The ISP or operator providing the Internet service.'))
contract = forms.CharField(required=False, max_length=256, label=_("Contract"), help_text=_('The specific contract at the ISP provider. (please be as specific as possible)'))
media = forms.ChoiceField(required=False, choices=(('',''),)+tuple(sorted(MEDIA,key=itemgetter(1))), label=_('Is the Internet connection over mobile or fixed line?'))
def search(self):
# By default, teh search field is q. So let's check if it's empty
if not self.cleaned_data['q']:
# By default, the search field is q. So let's check if it's empty
if not self.cleaned_data['q'] or self.cleaned_data['q'] == '':
sqs = SearchQuerySet().all()
else:
sqs = super(SearchViolation, self).search()
......
......@@ -22,6 +22,8 @@ from email.header import Header
from urlparse import urljoin
from BeautifulSoup import BeautifulSoup, Comment as BComment
from operator import itemgetter
from haystack.generic_views import SearchView
from forms import SearchViolation
def sanitizeHtml(value, base_url=None):
rjs = r'[\s]*(&#x.{1,7})?'.join(list('javascript:'))
......@@ -311,3 +313,6 @@ def asods(request):
response.write(f.read())
f.close()
return response
class ViolationSearchView(SearchView):
form_class = SearchViolation
......@@ -3,8 +3,8 @@ from django.views.generic import TemplateView, RedirectView
from django.conf import settings
from django.contrib import admin
from bt import views as bt
from bt.forms import SearchViolation
from bt.feeds import RssSiteNewsFeed, AtomSiteNewsFeed
from bt.api import APIResource, OperatorResource
api_resource = APIResource()
......@@ -82,8 +82,10 @@ urlpatterns = patterns('',
include(api_resource.urls)),
url(r'^api/',
include(operator_api_resource.urls)),
url(r'^search/',
include('haystack.urls')),
#url(r'^search/',
# include('haystack.urls')),
url(r'^search/$',
bt.ViolationSearchView.as_view()),
)
if settings.DEV_SERVER == True:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment