Commit cd6d0570 authored by EL HASSANE GARGEM's avatar EL HASSANE GARGEM
Browse files

add captcha to contact

parent d1d83a07
from django import forms from django import forms
from django.contrib.auth.forms import UserChangeForm, UserCreationForm from django.contrib.auth.forms import UserChangeForm, UserCreationForm
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from captcha.fields import CaptchaField
from bootstrap.forms import BootstrapFormMixin from bootstrap.forms import BootstrapFormMixin
from users.models import Invitation, User, ContactUs from users.models import Invitation, User, ContactUs
...@@ -56,7 +57,10 @@ class ProfileForm(BootstrapFormMixin, forms.ModelForm): ...@@ -56,7 +57,10 @@ class ProfileForm(BootstrapFormMixin, forms.ModelForm):
class ContactUsForm(BootstrapFormMixin, forms.ModelForm): class ContactUsForm(BootstrapFormMixin, forms.ModelForm):
message = forms.CharField(label="Message : Please precise your institution or research center if applicable", widget=forms.Textarea(attrs={'placeholder':'Message : Please precise your institution or research center if applicable' }))
captcha = CaptchaField()
class Meta: class Meta:
model = ContactUs model = ContactUs
fields = ('name','email','message') fields = ('name','email','message','captcha')
...@@ -62,6 +62,7 @@ INSTALLED_APPS = [ ...@@ -62,6 +62,7 @@ INSTALLED_APPS = [
'rest_framework', 'rest_framework',
'rest_framework.authtoken', 'rest_framework.authtoken',
'compressor', 'compressor',
'captcha',
'bootstrap', 'bootstrap',
'versioning', 'versioning',
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
{% render_field form.name %} {% render_field form.name %}
{% render_field form.email %} {% render_field form.email %}
{% render_field form.message %} {% render_field form.message %}
{{ form.captcha }}
<input type="submit" value="{% trans 'Send' %}" class="btn btn-success btn-block my-3" {% if object %}autofocus{% endif %}> <input type="submit" value="{% trans 'Send' %}" class="btn btn-success btn-block my-3" {% if object %}autofocus{% endif %}>
</fieldset> </fieldset>
</form> </form>
......
...@@ -26,7 +26,8 @@ urlpatterns = [ ...@@ -26,7 +26,8 @@ urlpatterns = [
path('api/', include('api.urls', namespace='api')), path('api/', include('api.urls', namespace='api')),
# sandbox # sandbox
path('baseline-editor/', TemplateView.as_view(template_name='baseline_editor.html')) path('baseline-editor/', TemplateView.as_view(template_name='baseline_editor.html')),
path(r'captcha/', include('captcha.urls')),
] ]
if settings.DEBUG: if settings.DEBUG:
......
...@@ -22,3 +22,4 @@ requests==2.21.0 ...@@ -22,3 +22,4 @@ requests==2.21.0
numpy>=1.17 numpy>=1.17
django-compressor==2.4 django-compressor==2.4
albumentations albumentations
django-simple-captcha==0.5.12
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