mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-25 17:32:16 +00:00
Merged in recaptcha (pull request #28)
Add recaptcha to all public facing pages.
This commit is contained in:
@@ -48,6 +48,7 @@ INSTALLED_APPS = (
|
|||||||
'debug_toolbar',
|
'debug_toolbar',
|
||||||
'registration',
|
'registration',
|
||||||
'reversion',
|
'reversion',
|
||||||
|
'captcha',
|
||||||
'widget_tweaks',
|
'widget_tweaks',
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -149,6 +150,11 @@ LOGOUT_URL = '/user/logout'
|
|||||||
|
|
||||||
ACCOUNT_ACTIVATION_DAYS = 7
|
ACCOUNT_ACTIVATION_DAYS = 7
|
||||||
|
|
||||||
|
# reCAPTCHA settings
|
||||||
|
RECAPTCHA_PUBLIC_KEY = '6Le16gUTAAAAAO5f-6te_x0NjWmF65_h7saBI6Cg'
|
||||||
|
RECAPTCHA_PRIVATE_KEY = '***REMOVED***'
|
||||||
|
NOCAPTCHA = True
|
||||||
|
|
||||||
# Email
|
# Email
|
||||||
EMAILER_TEST = False
|
EMAILER_TEST = False
|
||||||
if not DEBUG or EMAILER_TEST:
|
if not DEBUG or EMAILER_TEST:
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ from django import forms
|
|||||||
from django.utils import formats
|
from django.utils import formats
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
|
from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm
|
||||||
from registration.forms import RegistrationFormUniqueEmail
|
from registration.forms import RegistrationFormUniqueEmail
|
||||||
|
from captcha.fields import ReCaptchaField
|
||||||
import simplejson
|
import simplejson
|
||||||
|
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
@@ -14,6 +16,7 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
|
|||||||
last_name = forms.CharField(required=False, max_length=50)
|
last_name = forms.CharField(required=False, max_length=50)
|
||||||
initials = forms.CharField(required=True, max_length=5)
|
initials = forms.CharField(required=True, max_length=5)
|
||||||
phone = forms.CharField(required=False, max_length=13)
|
phone = forms.CharField(required=False, max_length=13)
|
||||||
|
captcha = ReCaptchaField()
|
||||||
|
|
||||||
def clean_initials(self):
|
def clean_initials(self):
|
||||||
"""
|
"""
|
||||||
@@ -23,6 +26,13 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
|
|||||||
raise forms.ValidationError("These initials are already in use. Please supply different initials.")
|
raise forms.ValidationError("These initials are already in use. Please supply different initials.")
|
||||||
return self.cleaned_data['initials']
|
return self.cleaned_data['initials']
|
||||||
|
|
||||||
|
# Login form
|
||||||
|
class LoginForm(AuthenticationForm):
|
||||||
|
captcha = ReCaptchaField(label='Captcha')
|
||||||
|
|
||||||
|
class PasswordReset(PasswordResetForm):
|
||||||
|
captcha = ReCaptchaField(label='Captcha')
|
||||||
|
|
||||||
# Events Shit
|
# Events Shit
|
||||||
class EventForm(forms.ModelForm):
|
class EventForm(forms.ModelForm):
|
||||||
datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS
|
datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from django.conf.urls import patterns, include, url
|
from django.conf.urls import patterns, include, url
|
||||||
from django.contrib.auth.decorators import login_required
|
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 django.views.generic import RedirectView
|
||||||
|
|
||||||
from PyRIGS.decorators import permission_required_with_403
|
from PyRIGS.decorators import permission_required_with_403
|
||||||
@@ -14,6 +14,7 @@ urlpatterns = patterns('',
|
|||||||
url(r'^closemodal/$', views.CloseModal.as_view(), name='closemodal'),
|
url(r'^closemodal/$', views.CloseModal.as_view(), name='closemodal'),
|
||||||
|
|
||||||
url('^user/login/$', 'RIGS.views.login', name='login'),
|
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
|
# People
|
||||||
url(r'^people/$', permission_required_with_403('RIGS.view_person')(views.PersonList.as_view()),
|
url(r'^people/$', permission_required_with_403('RIGS.view_person')(views.PersonList.as_view()),
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ def login(request, **kwargs):
|
|||||||
else:
|
else:
|
||||||
from django.contrib.auth.views import login
|
from django.contrib.auth.views import login
|
||||||
|
|
||||||
return login(request)
|
return login(request, authentication_form=forms.LoginForm)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ dj-database-url==0.3.0
|
|||||||
dj-static==0.0.6
|
dj-static==0.0.6
|
||||||
django-debug-toolbar==1.2.2
|
django-debug-toolbar==1.2.2
|
||||||
django-ical==1.3
|
django-ical==1.3
|
||||||
|
django-recaptcha==1.0.4
|
||||||
django-registration-redux==1.1
|
django-registration-redux==1.1
|
||||||
django-reversion==1.8.5
|
django-reversion==1.8.5
|
||||||
django-toolbelt==0.0.1
|
django-toolbelt==0.0.1
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
{% include 'form_errors.html' %}
|
{% include 'form_errors.html' %}
|
||||||
<div class="col-md-4 col-md-offset-4">
|
<div class="col-sm-6 col-sm-offset-3 col-lg-4 col-lg-offset-4">
|
||||||
|
|
||||||
<form action="{% url 'login' %}" method="post" role="form">{% csrf_token %}
|
<form action="{% url 'login' %}" method="post" role="form">{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -12,6 +12,12 @@
|
|||||||
<label for="{{ form.password.id_for_label }}">{{ form.password.label }}</label>
|
<label for="{{ form.password.id_for_label }}">{{ form.password.label }}</label>
|
||||||
{% render_field form.password class+="form-control" placeholder=form.password.label %}
|
{% render_field form.password class+="form-control" placeholder=form.password.label %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.captcha.id_for_label }}">{{ form.captcha.label }}</label>
|
||||||
|
<div class="text-center">
|
||||||
|
{{ form.captcha }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<a href="{% url 'registration_register' %}" class="btn">Register</a>
|
<a href="{% url 'registration_register' %}" class="btn">Register</a>
|
||||||
<a href="{% url 'password_reset' %}" class="btn">Forgotten Password</a>
|
<a href="{% url 'password_reset' %}" class="btn">Forgotten Password</a>
|
||||||
<input type="submit" value="Login" class="btn btn-primary"/>
|
<input type="submit" value="Login" class="btn btn-primary"/>
|
||||||
|
|||||||
@@ -21,11 +21,12 @@
|
|||||||
{% render_field form.email type="email" class+="form-control" %}
|
{% render_field form.email type="email" class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12">
|
<div class="form-group">
|
||||||
<div class="pull-right">
|
<div class="col-sm-10 col-md-8 col-md-offset-2">
|
||||||
<div class="form-group">
|
{{ form.captcha }}
|
||||||
<input type="submit" value="Submit" class="btn btn-primary" />
|
</div>
|
||||||
</div>
|
<div class="col-sm-2 text-right">
|
||||||
|
<input type="submit" value="Submit" class="btn btn-primary" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user