diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index 8f776eed..a3f7aee3 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -48,6 +48,7 @@ INSTALLED_APPS = ( 'debug_toolbar', 'registration', 'reversion', + 'captcha', 'widget_tweaks', ) @@ -149,6 +150,11 @@ LOGOUT_URL = '/user/logout' ACCOUNT_ACTIVATION_DAYS = 7 +# reCAPTCHA settings +RECAPTCHA_PUBLIC_KEY = '6Le16gUTAAAAAO5f-6te_x0NjWmF65_h7saBI6Cg' +RECAPTCHA_PRIVATE_KEY = '6Le16gUTAAAAAByo-ZxRRX3RKyoBngf7ms3dnoEW' +NOCAPTCHA = True + # Email EMAILER_TEST = False if not DEBUG or EMAILER_TEST: diff --git a/RIGS/forms.py b/RIGS/forms.py index 3f38f9d5..8a019409 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -3,7 +3,9 @@ from django import forms from django.utils import formats from django.conf import settings from django.core import serializers +from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm from registration.forms import RegistrationFormUniqueEmail +from captcha.fields import ReCaptchaField import simplejson from RIGS import models @@ -14,6 +16,7 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): last_name = forms.CharField(required=False, max_length=50) initials = forms.CharField(required=True, max_length=5) phone = forms.CharField(required=False, max_length=13) + captcha = ReCaptchaField() def clean_initials(self): """ @@ -23,6 +26,13 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): raise forms.ValidationError("These initials are already in use. Please supply different initials.") return self.cleaned_data['initials'] +# Login form +class LoginForm(AuthenticationForm): + captcha = ReCaptchaField(label='Captcha') + +class PasswordReset(PasswordResetForm): + captcha = ReCaptchaField(label='Captcha') + # Events Shit class EventForm(forms.ModelForm): datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS diff --git a/RIGS/urls.py b/RIGS/urls.py index dfe725c2..cab2532c 100644 --- a/RIGS/urls.py +++ b/RIGS/urls.py @@ -1,6 +1,6 @@ from django.conf.urls import patterns, include, url from django.contrib.auth.decorators import login_required -from RIGS import views, rigboard, finance, ical +from RIGS import views, rigboard, finance, ical, forms from django.views.generic import RedirectView from PyRIGS.decorators import permission_required_with_403 @@ -14,6 +14,7 @@ urlpatterns = patterns('', url(r'^closemodal/$', views.CloseModal.as_view(), name='closemodal'), url('^user/login/$', 'RIGS.views.login', name='login'), + url(r'^user/password_reset/$', 'django.contrib.auth.views.password_reset', {'password_reset_form':forms.PasswordReset}), # People url(r'^people/$', permission_required_with_403('RIGS.view_person')(views.PersonList.as_view()), diff --git a/RIGS/views.py b/RIGS/views.py index 38cbe99a..472f20ec 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -30,7 +30,7 @@ def login(request, **kwargs): else: from django.contrib.auth.views import login - return login(request) + return login(request, authentication_form=forms.LoginForm) """ diff --git a/requirements.txt b/requirements.txt index 9a46f2f2..3a90e9d6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ dj-database-url==0.3.0 dj-static==0.0.6 django-debug-toolbar==1.2.2 django-ical==1.3 +django-recaptcha==1.0.4 django-registration-redux==1.1 django-reversion==1.8.5 django-toolbelt==0.0.1 diff --git a/templates/registration/loginform.html b/templates/registration/loginform.html index 01c0b900..1ad39bd7 100644 --- a/templates/registration/loginform.html +++ b/templates/registration/loginform.html @@ -1,7 +1,7 @@ {% load url from future %} {% load widget_tweaks %} {% include 'form_errors.html' %} -
+
{% csrf_token %}
@@ -12,6 +12,12 @@ {% render_field form.password class+="form-control" placeholder=form.password.label %}
+
+ +
+ {{ form.captcha }} +
+
Register Forgotten Password diff --git a/templates/registration/password_reset_form.html b/templates/registration/password_reset_form.html index bbe77669..b9358488 100644 --- a/templates/registration/password_reset_form.html +++ b/templates/registration/password_reset_form.html @@ -21,11 +21,12 @@ {% render_field form.email type="email" class+="form-control" %}
-
-
-
- -
+
+
+ {{ form.captcha }} +
+
+