user form management with django registration
authorcavaliet
Fri, 11 Jul 2014 16:49:14 +0200
changeset 292 f6742c41d7a3
parent 291 44af3e5e4114
child 293 b33caeba7faa
user form management with django registration
src/hdabo/settings.py
src/hdabo/templates/registration/activate.html
src/hdabo/templates/registration/activation_complete.html
src/hdabo/templates/registration/activation_email.txt
src/hdabo/templates/registration/activation_email_subject.txt
src/hdabo/templates/registration/login.html
src/hdabo/templates/registration/password_change_done.html
src/hdabo/templates/registration/password_change_form.html
src/hdabo/templates/registration/password_reset_complete.html
src/hdabo/templates/registration/password_reset_confirm.html
src/hdabo/templates/registration/password_reset_done.html
src/hdabo/templates/registration/password_reset_email.html
src/hdabo/templates/registration/password_reset_form.html
src/hdabo/templates/registration/registration_complete.html
src/hdabo/templates/registration/registration_form.html
src/hdabo/urls.py
src/hdabo/views.py
virtualenv/res/lib/lib_create_env.py
virtualenv/res/src/django-registration-1.5-c71d5b8e2735.zip
virtualenv/web/res/res_create_env.py
--- a/src/hdabo/settings.py	Thu Jul 10 16:17:00 2014 +0200
+++ b/src/hdabo/settings.py	Fri Jul 11 16:49:14 2014 +0200
@@ -118,7 +118,8 @@
 )
 
 INSTALLED_APPS = (
-    'south',              
+    'hdabo',
+    'south',
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
@@ -127,8 +128,8 @@
     'django.contrib.staticfiles',
     'django.contrib.admin',
     'django_extensions',
+    'registration',
     'haystack',
-    'hdabo',
     'hdalab',
 )
 
@@ -154,6 +155,8 @@
 # User class after migration to django > 1.6.5
 AUTH_USER_MODEL = 'hdabo.User'
 
+ACCOUNT_ACTIVATION_DAYS = 7
+
 from hdabo.config import * #@UnusedWildImport
 
 if 'LOGIN_REDIRECT_URL' not in locals():
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/activate.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,13 @@
+{% extends "hdabo_base.html" %}
+{% load i18n %}
+
+{% block content %}
+<div class="register">
+	{% if account %}
+	<p>{% trans "Account successfully activated" %}</p>
+	<p><a href="{% url 'auth_login' %}">{% trans "Log in" %}</a></p>
+	{% else %}
+	<p>{% trans "Account activation failed" %}</p>
+	{% endif %}
+</div>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/activation_complete.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,10 @@
+{% extends "hdabo_base.html" %}
+{% load i18n %}
+
+{% block content %}
+<div class="register">
+    <p>{% trans "Your account is now activated." %}</p>
+    <p>&nbsp;</p>
+    <p><a href="{% url 'login' %}">{% trans "Log in" %}</a></p>
+</div>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/activation_email.txt	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,6 @@
+{% load i18n %}
+{% trans "Activate account at" %} {{ site.name }}:
+
+http://{{ site.domain }}{% url 'registration_activate' activation_key %}
+
+{% blocktrans %}Link is valid for {{ expiration_days }} days.{% endblocktrans %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/activation_email_subject.txt	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,1 @@
+{% load i18n %}{% trans "Account activation on" %} {{ site.name }}
--- a/src/hdabo/templates/registration/login.html	Thu Jul 10 16:17:00 2014 +0200
+++ b/src/hdabo/templates/registration/login.html	Fri Jul 11 16:49:14 2014 +0200
@@ -1,28 +1,25 @@
 {% extends "hdabo_base.html" %}
+{% load static %}
 {% load i18n %}
-    {% block content %}
-    {{block.super}}
-    {% if form.errors %}
+
+{% block title %}{% trans "Login" %}{% endblock %}
+
+{% block content %}
+    <div class="register">
+        {% if form.errors %}
         <p class="error">{% trans "Sorry, that's not a valid username or password." %}</p>
-    {% endif %}
-       <div class="span-24 last">
-         <form action="" method='post' id="login-form">
-             <div id="loginform_div" class="span-12">
-             {% csrf_token %}
-             <input type="hidden" name="next" value="{{ next }}" />
-             <div id="login_fields_list">
-             <table>
-             {{form.as_table}}
-             </table>
-             </div>
-             <div>
-                 <a href="{% url 'django.contrib.auth.views.password_reset'  %}" >{% trans "Forget password?" %}</a>
-             </div>
-             <div id="submitcontent-buttons-login" class="span-24 last">
-                 <button class="button"type="submit" value="login">{% trans "login" %}</button>
-             </div>
-             </div>
-         </form>
-     </div> 
-    {% endblock %}
-    
\ No newline at end of file
+        {% endif %}
+        <form action="" method='post' id="login-form">
+            {% csrf_token %}
+            <input type="hidden" name="next" value="{% if next %}{{ next }}{% else %}{% url 'home' %}{% endif %}" />
+            {{form.as_p}}
+            <button class="button"type="submit" value="login">{% trans "login" %}</button>
+        </form>
+        <p>&nbsp;</p>
+        <p><a href="{% url 'registration_register' %}">{% trans "Still not a user ? Create an account" %}</a>
+        <p><a href="{% url 'auth_password_reset' %}">{% trans "Forgot password ?" %}</a>
+    </div>
+{% endblock %}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/password_change_done.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,8 @@
+{% extends "hdabo_base.html" %}
+{% load i18n %}
+
+{% block content %}
+<div class="register">
+    <p>{% trans "Password changed" %}</p>
+</div>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/password_change_form.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,12 @@
+{% extends "hdabo_base.html" %}
+{% load i18n %}
+
+{% block content %}
+<div class="register">
+	<form method="post" action=".">
+	  {% csrf_token %} 
+	  {{ form.as_p }}
+	  <input type="submit" value="{% trans 'Submit' %}" />
+	</form>
+</div>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/password_reset_complete.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,9 @@
+{% extends "hdabo_base.html" %}
+{% load i18n %}
+
+{% block content %}
+<div class="register">
+	<p>{% trans "Password reset successfully" %}</p>
+	<p><a href="{% url 'auth_login' %}">{% trans "Log in" %}</a></p>
+</div>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/password_reset_confirm.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,16 @@
+{% extends "hdabo_base.html" %}
+{% load i18n %}
+
+{% block content %}
+<div class="register">
+	{% if validlink %}
+	<form method="post" action=".">
+	  {% csrf_token %} 
+	  {{ form.as_p }}
+	  <input type="submit" value="{% trans 'Submit' %}" />
+	</form>
+	{% else %}
+	<p>{% trans "Password reset failed" %}</p>
+	{% endif %}
+</div>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/password_reset_done.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,8 @@
+{% extends "hdabo_base.html" %}
+{% load i18n %}
+
+{% block content %}
+<div class="register">
+    <p>{% trans "Email with password reset instructions has been sent." %}</p>
+</div>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/password_reset_email.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,5 @@
+{% load i18n %}
+{% blocktrans %}Reset password at {{ site_name }}{% endblocktrans %}:
+{% block reset_link %}
+{{ protocol }}://{{ domain }}{% url 'auth_password_reset_confirm' uidb36=uid token=token %}
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/password_reset_form.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,12 @@
+{% extends "hdabo_base.html" %}
+{% load i18n %}
+
+{% block content %}
+<div class="register">
+	<form method="post" action=".">
+	  {% csrf_token %} 
+	  {{ form.as_p }}
+	  <input type="submit" value="{% trans 'Submit' %}" />
+	</form>
+</div>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/registration_complete.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,8 @@
+{% extends "hdabo_base.html" %}
+{% load i18n %}
+
+{% block content %}
+<div class="register">
+    <p>{% trans "You are now registered. Activation email sent." %}</p>
+</div>
+{% endblock %}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdabo/templates/registration/registration_form.html	Fri Jul 11 16:49:14 2014 +0200
@@ -0,0 +1,12 @@
+{% extends "hdabo_base.html" %}
+{% load i18n %}
+
+{% block content %}
+<div class="register">
+	<form method="post" action=".">
+	  {% csrf_token %}
+	  {{ form.as_p }}
+	  <input type="submit" value="{% trans 'Submit' %}" />
+	</form>
+</div>
+{% endblock %}
--- a/src/hdabo/urls.py	Thu Jul 10 16:17:00 2014 +0200
+++ b/src/hdabo/urls.py	Fri Jul 11 16:49:14 2014 +0200
@@ -1,6 +1,6 @@
 from django.conf.urls import patterns, include, url
 from django.contrib import admin
-from django.contrib.auth import urls as auth_url
+from django.contrib.auth import urls as auth_url, views as auth_views
 from django.contrib.auth.decorators import login_required
 from .views import AddOrUpdateFolder, Folders, SearchDatasheet, DeleteFolder
 from hdalab import urls as hdalab_url
@@ -19,6 +19,8 @@
 
     # Uncomment the next line to enable the admin:
     url(r'^accounts/', include(auth_url)),
+    url(r'^accounts/password/reset/confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', auth_views.password_reset_confirm, name='password_reset_confirm'),
+    url(r'^accounts/', include('registration.backends.default.urls')),
     url(r'^logout/', 'django.contrib.auth.views.logout_then_login'),
     url(r'^admin/', include(admin.site.urls)),
     url(r'^search/', include('haystack.urls')),
--- a/src/hdabo/views.py	Thu Jul 10 16:17:00 2014 +0200
+++ b/src/hdabo/views.py	Fri Jul 11 16:49:14 2014 +0200
@@ -15,7 +15,7 @@
 from hdabo.utils import OrderedDict, remove_accents, normalize
 from hdabo.wp_utils import (normalize_tag, query_wikipedia_title, get_or_create_tag, process_tag, reorder_datasheet_tags)
 from wikitools import wiki
-import django.utils.simplejson as json
+import json
 import re
 from django.views.generic.base import TemplateView, View
 from haystack.views import SearchView
--- a/virtualenv/res/lib/lib_create_env.py	Thu Jul 10 16:17:00 2014 +0200
+++ b/virtualenv/res/lib/lib_create_env.py	Fri Jul 11 16:49:14 2014 +0200
@@ -19,6 +19,7 @@
     'DISTRIBUTE': {'setup': 'distribute', 'url':'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.24.tar.gz', 'local':"distribute-0.6.24.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
     'DJANGO': {'setup': 'django', 'url': 'http://www.djangoproject.com/download/1.6.5/tarball/', 'local':"Django-1.6.5.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
     'DJANGO-EXTENSIONS': { 'setup': 'django-extensions', 'url':'https://github.com/django-extensions/django-extensions/tarball/1.3.7', 'local':"django-extensions-1.3.7.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
+    'REGISTRATION': { 'setup': 'registration', 'url':'https://bitbucket.org/LinnTroll/django-registration-1.5/get/c71d5b8e2735.zip', 'local':"django-registration-1.5-c71d5b8e2735.zip", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
     'HTTPLIB2': { 'setup': 'python-httplib2', 'url':'http://code.google.com/p/httplib2/downloads/detail?name=httplib2-0.7.4.tar.gz&can=2&q=', 'local':"httplib2-0.7.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
     'SOUTH': { 'setup': 'South', 'url':'http://www.aeracode.org/releases/south/south-0.8.4.tar.gz', 'local':"south-0.8.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
     'PYCRYPTO': {'setup': 'pycrypto', 'url':'https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz', 'local':'pycrypto-2.6.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
Binary file virtualenv/res/src/django-registration-1.5-c71d5b8e2735.zip has changed
--- a/virtualenv/web/res/res_create_env.py	Thu Jul 10 16:17:00 2014 +0200
+++ b/virtualenv/web/res/res_create_env.py	Fri Jul 11 16:49:14 2014 +0200
@@ -10,6 +10,7 @@
     #'PIL', 
     'DJANGO',
     'DJANGO-EXTENSIONS',
+    'REGISTRATION',
     'SOUTH',
     'HTTPLIB2',
     'HAYSTACK',