Commit ac349d94 authored by Okhin's avatar Okhin
Browse files

Displaying the captchas field

parent f68dce81
...@@ -145,11 +145,9 @@ def sendverifymail(service,to,body): ...@@ -145,11 +145,9 @@ def sendverifymail(service,to,body):
return actid return actid
class AddForm(FormView): class AddForm(FormView):
model = Violation
template_name = 'index.html' template_name = 'index.html'
form_class = AddViolation form_class = AddViolation
success_url = '/' success_url = '/'
context_object_name = 'violations'
def form_valid(self, form): def form_valid(self, form):
msg=_("Thank you for submitting a new report. To finalize your submission please confirm using your validation key.\nYour verification key is %s/%s%s\nPlease note that reports are moderated, it might take some time before your report appears online. Thank you for your patience.") msg=_("Thank you for submitting a new report. To finalize your submission please confirm using your validation key.\nYour verification key is %s/%s%s\nPlease note that reports are moderated, it might take some time before your report appears online. Thank you for your patience.")
...@@ -167,7 +165,8 @@ class AddForm(FormView): ...@@ -167,7 +165,8 @@ class AddForm(FormView):
contractual = form.cleaned_data['contractual'], contractual = form.cleaned_data['contractual'],
contract_excerpt = sanitizeHtml(form.cleaned_data['contract_excerpt']), contract_excerpt = sanitizeHtml(form.cleaned_data['contract_excerpt']),
loophole = form.cleaned_data['loophole'], loophole = form.cleaned_data['loophole'],
activationid = actid activationid = actid,
old = False
) )
v.save() v.save()
#c=Confirmation(key='', email=form.cleaned_data['email'], violation=v) #c=Confirmation(key='', email=form.cleaned_data['email'], violation=v)
...@@ -181,7 +180,7 @@ class AddForm(FormView): ...@@ -181,7 +180,7 @@ class AddForm(FormView):
violation=v, violation=v,
) )
c.save() c.save()
for f in request.FILES.getlist('attachments[]'): for f in self.request.FILES.getlist('attachments[]'):
a=Attachment(comment=c, name=f.name, type=f.content_type) a=Attachment(comment=c, name=f.name, type=f.content_type)
m = hashlib.sha256() m = hashlib.sha256()
for chunk in f.chunks(): for chunk in f.chunks():
...@@ -189,7 +188,7 @@ class AddForm(FormView): ...@@ -189,7 +188,7 @@ class AddForm(FormView):
sname=m.hexdigest() sname=m.hexdigest()
a.storage.save(sname,f) a.storage.save(sname,f)
a.save() a.save()
messages.add_message(request, messages.INFO, _('Thank you for submitting this report, you will receive a verification email immediately, if not check your spam folder.')) messages.add_message(self.request, messages.INFO, _('Thank you for submitting this report, you will receive a verification email immediately, if not check your spam folder.'))
return super(AddForm, self).form_valid(form) return super(AddForm, self).form_valid(form)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
......
...@@ -145,8 +145,17 @@ ...@@ -145,8 +145,17 @@
<h2>{% trans "Add New Case" %}</h2> <h2>{% trans "Add New Case" %}</h2>
</div> </div>
<div class="panel-body"> <div class="panel-body">
{% if forms.error %}
{% for field in form %}
{% for error in field.error %}
<div class="alert alert-error">
{{ error|escape }}
</div>
{% endfor %}
{% endfor %}
{% endif %}
<p>{% trans "Please report cases of zero-rating (services which are excluded from your download limit), specialised services or the blocking, throttling or prioritisation of online services. For a more detailed description of what to report, check our <a href='/about/#guidelines'>guidelines</a>." %} <p>{% trans "Please report cases of zero-rating (services which are excluded from your download limit), specialised services or the blocking, throttling or prioritisation of online services. For a more detailed description of what to report, check our <a href='/about/#guidelines'>guidelines</a>." %}
<form name="addForm" enctype="multipart/form-data" action="{% root_url %}/add/" method="post" class="form"> <form name="addForm" enctype="multipart/form-data" action="/" method="post" class="form">
{% csrf_token %} {% csrf_token %}
{% bootstrap_field form.resource_name %} {% bootstrap_field form.resource_name %}
{% bootstrap_field form.country %} {% bootstrap_field form.country %}
...@@ -165,7 +174,7 @@ ...@@ -165,7 +174,7 @@
{% bootstrap_field form.consent %} {% bootstrap_field form.consent %}
{% bootstrap_field form.email %} {% bootstrap_field form.email %}
{% bootstrap_field form.nick %} {% bootstrap_field form.nick %}
{% bootstrap_field form.email %} {% bootstrap_field form.captcha %}
{% buttons %} {% buttons %}
<button type="submit" class="btn btn-primary">{% trans "save" %}</button> <button type="submit" class="btn btn-primary">{% trans "save" %}</button>
{% endbuttons %} {% endbuttons %}
......
Supports Markdown
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