Commits

Anonymous committed e263c55

Version 0.6

Comments (0)

Files changed (8)

 django-registration changelog
 =============================
 
+Version 0.6, 29 July 2008:
+--------------------------
+
+* Packaged from revision 166 in Subversion.
+
+* Fixed a multiple-objects exception in
+  ``RegistrationFormUniqueEmail`` when multiple users already have the
+  same email address.
+
+* Changed the ``success_url`` of the ``register()`` view to use
+  reverse URL resolution.
+
+* Added an ``extra_context`` argument to the ``register`` and
+  ``activate`` views, mimicking its functionality in Django's generic
+  views.
+
+* BACKWARDS-INCOMPATIBLE CHANGE: Switched the admin declaration to be
+  compliant with the newforms-admin refactor; the admin declaration
+  now lives in ``registration/admin.py``.
+
+* BACKWARDS-INCOMPATIBLE CHANGE: Switched form imports from using
+  ``django.newforms`` to using ``django.forms``; the old style now
+  raises a deprecation warning on Django trunk and on Django 1.0
+  alpha.
+
 
 Version 0.5, 4 June 2008:
 -------------------------

docs/overview.txt

 you'll need to do so. You can download a packaged version of the
 latest release here::
 
-    http://django-registration.googlecode.com/files/registration-0.4p2.tar.gz
+    http://django-registration.googlecode.com/files/django-registration-0.6.tar.gz
 
 Open up the package (on most operating systems you can double-click,
-or you can use the command ``tar zxvf registration-0.4p2.tar.gz`` to
+or you can use the command ``tar zxvf registration-0.6.tar.gz`` to
 manually unpack it), and, at a command line, navigate to the directory
-``registration-0.4p2``, then type:
+``registration-0.6``, then type:
 
     python setup.py install
 
 
     sudo python setup.py install
 
-Alternatively, you can do a Subversion checkout to get the latest
+Alternatively, you do a Subversion checkout to get the latest
 development code (though this may also include bugs which have not yet
 been fixed)::
 
     svn co http://django-registration.googlecode.com/svn/trunk/registration/
 
-For best results, do that in a directory that's on your Python import
-path.
+For best results, do this in a directory that's on your Python path.
 
 
 Basic use
 Development
 ===========
 
-The `latest released version`_ of this application is 0.4, and is
+The `latest released version`_ of this application is 0.6, and is
 quite stable; it's already been deployed on a number of sites,
 including djangoproject.com. You can also obtain the absolute freshest
-code from `a Subversion checkout`_, but be warned that the code in SVN
-may not always be backwards-compatible, and may well contain bugs that
-haven't yet been fixed.
+code from `the development repository_`, but be warned that the
+development code may not always be backwards-compatible, and may well
+contain bugs that haven't yet been fixed.
 
-This document covers the 0.4 release of django-registration; new
-features introduced in Subversion will be added to the documentation
-at the time of the next packaged release.
+This document covers the 0.6 release of django-registration; new
+features introduced in the development trunk will be added to the
+documentation at the time of the next packaged release.
 
-.. _latest released version: 
-.. _a Subversion checkout: http://django-registration.googlecode.com/svn/trunk/registration/
+.. _latest released version: http://django-registration.googlecode.com/files/django-registration-0.6.tar.gz
+.. _the development repository: http://django-registration.googlecode.com/svn/trunk/registration/
 
 
 Changes from previous versions
 and has evolved to accomodate some changes which happened after the
 Django 0.96 release, so a stock copy of 0.96 will not work.
 
+Your Django project should have ``django.contrib.admin``,
+``django.contrib.auth`` and ``django.contrib.sites`` in its
+``INSTALLED_APPS`` setting.
+
 What this application does not do
 =================================
 
 check `the issues list`_ to see if it's already been reported. If not,
 open a new issue and I'll do my best to respond quickly.
 
-.. _project page on Google Code: http://code.google.com/p/django-registration/
+.. project page on Google Code: http://code.google.com/p/django-registration/
 .. _the issues list: http://code.google.com/p/django-registration/issues/list
-
 
 
 ``activate``
-=====================================
+============
 
-Activates a ``User``'s account, if their key is valid and hasn't
-expired.
+Activate a ``User``'s account from an activation key, if their key is
+valid and hasn't expired.
 
-By default, uses the template ``registration/activate.html``; to
+By default, use the template ``registration/activate.html``; to
 change this, pass the name of a template as the keyword argument
 ``template_name``.
 
     
 **Optional arguments**
 
+``extra_context``
+    A dictionary of variables to add to the template context. Any
+    callable object in this dictionary will be called to produce the
+    end result which appears in the context.
+
 ``template_name``
     A custom template to use.
 
     The number of days for which activation keys stay valid after
     registration.
 
+Any extra variables supplied in the ``extra_context`` argument (see
+above).
+
 **Template:**
     
 registration/activate.html or ``template_name`` keyword argument.
 ``register``
 ============
 
-Allows a new user to register an account.
+Allow a new user to register an account.
     
-Following successful registration, redirects to either
-``/accounts/register/complete/`` or, if supplied, the URL specified in
-the keyword argument ``success_url``.
-
+Following successful registration, issue a redirect; by default, this
+will be whatever URL corresponds to the named URL pattern
+``registration_complete``, which will be
+``/accounts/register/complete/`` if using the included URLConf. To
+change this, point that named pattern at another URL, or pass your
+preferred URL as the keyword argument ``success_url``.
+    
 By default, ``registration.forms.RegistrationForm`` will be used as
 the registration form; to change this, pass a different form class as
 the ``form_class`` keyword argument. The form class you specify must
 ``RegistrationManager.create_inactive_user`` in the file ``models.py``
 for details on how to write this function.
 
-By default, uses the template ``registration/registration_form.html``;
+By default, use the template ``registration/registration_form.html``;
 to change this, pass the name of a template as the keyword argument
 ``template_name``.
 
 ``form_class``
     The form class to use for registration.
 
+``extra_context``
+    A dictionary of variables to add to the template context. Any
+    callable object in this dictionary will be called to produce the
+    end result which appears in the context.
+
 ``profile_callback``
     A function which will be used to create a site-specific profile
     instance for the new ``User``.
 ``form``
     The registration form.
     
+Any extra variables supplied in the ``extra_context`` argument (see
+above).
+
 **Template:**
 
 registration/registration_form.html or ``template_name`` keyword

registration/admin.py

+from django.contrib import admin
+
+from registration.models import RegistrationProfile
+
+
+class RegistrationAdmin(admin.ModelAdmin):
+    list_display = ('__unicode__', 'activation_key_expired')
+    search_fields = ('user__username', 'user__first_name')
+
+
+admin.site.register(RegistrationProfile, RegistrationAdmin)

registration/forms.py

 """
 
 
-from django import newforms as forms
+from django import forms
 from django.core.validators import alnum_re
 from django.utils.translation import ugettext_lazy as _
 from django.contrib.auth.models import User
         site.
         
         """
-        try:
-            user = User.objects.get(email__iexact=self.cleaned_data['email'])
-        except User.DoesNotExist:
-            return self.cleaned_data['email']
-        raise forms.ValidationError(_(u'This email address is already in use. Please supply a different email address.'))
+        if User.objects.filter(email__iexact=self.cleaned_data['email']):
+            raise forms.ValidationError(_(u'This email address is already in use. Please supply a different email address.'))
+        return self.cleaned_data['email']
 
 
 class RegistrationFormNoFreeEmail(RegistrationForm):

registration/models.py

         verbose_name = _('registration profile')
         verbose_name_plural = _('registration profiles')
     
-    class Admin:
-        list_display = ('__unicode__', 'activation_key_expired')
-        search_fields = ('user__username', 'user__first_name')
-        
     def __unicode__(self):
         return u"Registration information for %s" % self.user
     

registration/views.py

 
 
 from django.conf import settings
+from django.core.urlresolvers import reverse
 from django.http import HttpResponseRedirect
 from django.shortcuts import render_to_response
 from django.template import RequestContext
              template_name='registration/activate.html',
              extra_context=None):
     """
-    Activate a ``User``'s account, if their key is valid and hasn't
-    expired.
+    Activate a ``User``'s account from an activation key, if their key
+    is valid and hasn't expired.
     
-    By default, uses the template ``registration/activate.html``; to
+    By default, use the template ``registration/activate.html``; to
     change this, pass the name of a template as the keyword argument
     ``template_name``.
     
+    **Required arguments**
+    
+    ``activation_key``
+       The activation key to validate and use for activating the
+       ``User``.
+    
+    **Optional arguments**
+       
+    ``extra_context``
+        A dictionary of variables to add to the template context. Any
+        callable object in this dictionary will be called to produce
+        the end result which appears in the context.
+    
+    ``template_name``
+        A custom template to use.
+    
     **Context:**
     
-    account
+    ``account``
         The ``User`` object corresponding to the account, if the
         activation was successful. ``False`` if the activation was not
         successful.
     
-    expiration_days
+    ``expiration_days``
         The number of days for which activation keys stay valid after
         registration.
     
-    Any values passed in the keyword argument ``extra_context`` (which
-    must be a dictionary) will be added to the context as well; any
-    values in ``extra_context`` which are callable will be called
-    prior to being added to the context.
-
+    Any extra variables supplied in the ``extra_context`` argument
+    (see above).
+    
     **Template:**
     
     registration/activate.html or ``template_name`` keyword argument.
                               context_instance=context)
 
 
-def register(request, success_url='/accounts/register/complete/',
+def register(request, success_url=None,
              form_class=RegistrationForm, profile_callback=None,
              template_name='registration/registration_form.html',
              extra_context=None):
     """
     Allow a new user to register an account.
     
-    Following successful registration, redirects to either
-    ``/accounts/register/complete/`` or, if supplied, the URL
-    specified in the keyword argument ``success_url``.
+    Following successful registration, issue a redirect; by default,
+    this will be whatever URL corresponds to the named URL pattern
+    ``registration_complete``, which will be
+    ``/accounts/register/complete/`` if using the included URLConf. To
+    change this, point that named pattern at another URL, or pass your
+    preferred URL as the keyword argument ``success_url``.
     
     By default, ``registration.forms.RegistrationForm`` will be used
     as the registration form; to change this, pass a different form
     ``RegistrationManager.create_inactive_user`` in the file
     ``models.py`` for details on how to write this function.
     
-    By default, uses the template
+    By default, use the template
     ``registration/registration_form.html``; to change this, pass the
     name of a template as the keyword argument ``template_name``.
     
+    **Required arguments**
+    
+    None.
+    
+    **Optional arguments**
+    
+    ``form_class``
+        The form class to use for registration.
+    
+    ``extra_context``
+        A dictionary of variables to add to the template context. Any
+        callable object in this dictionary will be called to produce
+        the end result which appears in the context.
+    
+    ``profile_callback``
+        A function which will be used to create a site-specific
+        profile instance for the new ``User``.
+    
+    ``success_url``
+        The URL to redirect to on successful registration.
+    
+    ``template_name``
+        A custom template to use.
+    
     **Context:**
     
-    form
+    ``form``
         The registration form.
     
-    Any values passed in the keyword argument ``extra_context`` (which
-    must be a dictionary) will be added to the context as well; any
-    values in ``extra_context`` which are callable will be called
-    prior to being added to the context.
-
+    Any extra variables supplied in the ``extra_context`` argument
+    (see above).
+    
     **Template:**
     
     registration/registration_form.html or ``template_name`` keyword
         form = form_class(data=request.POST, files=request.FILES)
         if form.is_valid():
             new_user = form.save(profile_callback=profile_callback)
-            return HttpResponseRedirect(success_url)
+            # success_url needs to be dynamically generated here; setting a
+            # a default value using reverse() will cause circular-import
+            # problems with the default URLConf for this application, which
+            # imports this file.
+            return HttpResponseRedirect(success_url or reverse('registration_complete'))
     else:
         form = form_class()
     
 
 
 setup(name='django-registration',
-      version='0.5',
+      version='0.6',
       description='An extensible user-registration application for Django',
       author='James Bennett',
       author_email='james@b-list.org',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.