]> git.parisson.com Git - teleforma.git/commitdiff
Add captcha to registration form
authorGuillaume Pellerin <yomguy@parisson.com>
Sun, 8 Feb 2015 21:54:48 +0000 (22:54 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Sun, 8 Feb 2015 21:54:48 +0000 (22:54 +0100)
example/settings.py
setup.py
teleforma/admin.py
teleforma/forms.py
teleforma/static/teleforma/css/teleforma.css
teleforma/templates/admin/base.html [deleted file]
teleforma/urls.py

index 2d178816a454cd8135e3f9ddac0912a5daed3c52..5ecbe116e8d1049c32dfbf16c86b0306c7d87c8d 100644 (file)
@@ -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',
+}
index b5ee84ae0ef6e3538c0f667858fc9e7c1e7c3740..44c7ca9f11fb88602e147694d18bbc619bbdba8d 100644 (file)
--- 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',
index c007b324b10bc1ba39d63729cb40b1af52ed9ee6..4cb3d0f88e8fe8dd72e1b526fa66edcc48f9f9c8 100644 (file)
@@ -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
index 312a27a7f19b4756b64b03ef08d69680e0063d5d..021db90e1307abc7a3ac1553c0c0f7f89f777f99 100644 (file)
@@ -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
index 41755657030c6238c7eb58b7ed3fd5e8d3f585f9..db2e8af180a36c57bddff41f85e60f5240e5470a 100644 (file)
@@ -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 (file)
index d5f4b3f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ LANGUAGE_CODE }}" xml:lang="{{ LANGUAGE_CODE }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
-<head>
-<title>{% block title %}{% endblock %}</title>
-<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{{ STATIC_URL }}admin/css/base.css{% endblock %}" />
-{% block extrastyle %}{% endblock %}
-<!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="{% block stylesheet_ie %}{{ STATIC_URL }}admin/css/ie.css{% endblock %}" /><![endif]-->
-{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{{ STATIC_URL }}admin/css/rtl.css{% endblock %}" />{% endif %}
-<script type="text/javascript">window.__admin_media_prefix__ = "{% filter escapejs %}{{ STATIC_URL }}admin/{% endfilter %}";</script>
-{% block extrahead %}{% endblock %}
-{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
-</head>
-{% load i18n %}
-
-<body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}">
-
-<!-- Container -->
-<div id="container">
-
-    {% if not is_popup %}
-    {% block breadcrumbs %}<div class="breadcrumbs"><a href="/">{% trans 'Home' %}</a>{% if title %} &rsaquo; {{ title }}{% endif %}</div>{% endblock %}
-    {% endif %}
-
-        {% if messages %}
-        <ul class="messagelist">{% for message in messages %}
-          <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
-       {% endfor %}</ul>
-        {% endif %}
-
-    <!-- Content -->
-    <div id="content" class="{% block coltype %}colM{% endblock %}">
-        {% block pretitle %}{% endblock %}
-        {% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}
-        {% block content %}
-        {% block object-tools %}{% endblock %}
-        {{ content }}
-        {% endblock %}
-        {% block sidebar %}{% endblock %}
-        <br class="clear" />
-    </div>
-    <!-- END Content -->
-
-    {% block footer %}<div id="footer"></div>{% endblock %}
-</div>
-<!-- END Container -->
-
-</body>
-</html>
index 389e644fc6c73a892af16bb1d70799b33febd644..9c25ac821cb608c11f77448d853916196d111ed5 100644 (file)
@@ -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')),
+
 )