From: Guillaume Pellerin Date: Sun, 8 Feb 2015 21:54:48 +0000 (+0100) Subject: Add captcha to registration form X-Git-Tag: 1.1~294^2~4 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=4c0e570189365dd4b4bbabbd1445b1ea3a032ff2;p=teleforma.git Add captcha to registration form --- diff --git a/example/settings.py b/example/settings.py index 2d178816..5ecbe116 100644 --- a/example/settings.py +++ b/example/settings.py @@ -149,6 +149,7 @@ INSTALLED_APPS = ( 'googletools', # 'telecaster', 'extra_views', + 'captcha', ) TEMPLATE_CONTEXT_PROCESSORS = ( @@ -206,4 +207,8 @@ TELEFORMA_EXAM_SCRIPT_UPLOAD = True JQCHAT_DISPLAY_COUNT = 50 JQCHAT_DISPLAY_TIME = 48 -BOX_API_TOKEN = 'D2pBaN8YqjGIfS0tKrgnMP93' \ No newline at end of file +BOX_API_TOKEN = 'D2pBaN8YqjGIfS0tKrgnMP93' + +SOUTH_MIGRATION_MODULES = { + 'captcha': 'captcha.south_migrations', +} diff --git a/setup.py b/setup.py index b5ee84ae..44c7ca9f 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,9 @@ setup( 'django-jqchat', 'django-googletools', 'crocodoc', + 'django-registration', 'django-extra-views', + 'django-simple-captcha', ], platforms=['OS Independent'], license='CeCILL v2', diff --git a/teleforma/admin.py b/teleforma/admin.py index c007b324..4cb3d0f8 100644 --- a/teleforma/admin.py +++ b/teleforma/admin.py @@ -23,6 +23,7 @@ class StudentAdmin(admin.ModelAdmin): model = Student exclude = ['options'] # inlines = [StudentPaymentInline] + search_fields = ['user__first_name', 'user__last_name', 'user__username',] class ProfessorProfileInline(admin.StackedInline): model = Professor diff --git a/teleforma/forms.py b/teleforma/forms.py index 312a27a7..021db90e 100644 --- a/teleforma/forms.py +++ b/teleforma/forms.py @@ -4,6 +4,7 @@ from teleforma.models import * from registration.forms import RegistrationForm from django.utils.translation import ugettext_lazy as _ from extra_views import CreateWithInlinesView, UpdateWithInlinesView, InlineFormSet +from captcha.fields import CaptchaField class ConferenceForm(ModelForm): @@ -14,6 +15,7 @@ class ConferenceForm(ModelForm): class UserForm(ModelForm): # first_name = forms.CharField(_('First name'), required=True) # last_name = forms.CharField(_('Last name'), required=True) + captcha = CaptchaField() class Meta: model = User diff --git a/teleforma/static/teleforma/css/teleforma.css b/teleforma/static/teleforma/css/teleforma.css index 41755657..db2e8af1 100644 --- a/teleforma/static/teleforma/css/teleforma.css +++ b/teleforma/static/teleforma/css/teleforma.css @@ -1717,3 +1717,22 @@ input,textarea{ font-size: 1.2em; } +form.register { + width: 40%; + font-size: 1.1em; + float: center; + margin-top: 1em; + margin-bottom: 4em; + margin-left: 25%; + border: 0px dotted #888; + padding: 1em; + background-color: #FFF; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; +} + +.register-error { + color: #BB0000; +} + diff --git a/teleforma/templates/admin/base.html b/teleforma/templates/admin/base.html deleted file mode 100644 index d5f4b3f1..00000000 --- a/teleforma/templates/admin/base.html +++ /dev/null @@ -1,48 +0,0 @@ - - - -{% block title %}{% endblock %} - -{% block extrastyle %}{% endblock %} - -{% if LANGUAGE_BIDI %}{% endif %} - -{% block extrahead %}{% endblock %} -{% block blockbots %}{% endblock %} - -{% load i18n %} - - - - -
- - {% if not is_popup %} - {% block breadcrumbs %}{% endblock %} - {% endif %} - - {% if messages %} - - {% endif %} - - -
- {% block pretitle %}{% endblock %} - {% block content_title %}{% if title %}

{{ title }}

{% endif %}{% endblock %} - {% block content %} - {% block object-tools %}{% endblock %} - {{ content }} - {% endblock %} - {% block sidebar %}{% endblock %} -
-
- - - {% block footer %}{% endblock %} -
- - - - diff --git a/teleforma/urls.py b/teleforma/urls.py index 389e644f..9c25ac82 100644 --- a/teleforma/urls.py +++ b/teleforma/urls.py @@ -121,6 +121,8 @@ urlpatterns = patterns('', # EXAM url(r'^', include('teleforma.exam.urls')), - (r'^accounts/register0/$', RegistrationView.as_view(), {'form_class':CustomRegistrationForm}), - (r'^accounts/register/$', UserAddView.as_view()), + # (r'^accounts/register0/$', RegistrationView.as_view(), {'form_class':CustomRegistrationForm}), + url(r'^accounts/register/$', UserAddView.as_view()), + url(r'^captcha/', include('captcha.urls')), + )