1. Marko Mrdjenovic
  2. django-registration-plus


django-registration-plus / registration / backends / invitational / urls.py

URLconf for registration and activation, using django-registration's
default backend.

If the default behavior of these views is acceptable to you, simply
use a line like this in your root URLconf to set up the default URLs
for registration::

    (r'^accounts/', include('registration.backends.default.urls')),

This will also automatically set up the views in
``django.contrib.auth`` at sensible default locations.

If you'd like to customize the behavior (e.g., by passing extra
arguments to the various views) or split up the URLs, feel free to set
up your own URL patterns for these views instead.


from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template

from registration.views import invite
from registration.views import activate
from registration.views import register

urlpatterns = patterns('',
    url(r'^invite/$', invite,
        {'backend': 'registration.backends.invitational.InvitationBackend'},
    url(r'^invite/complete/$', direct_to_template,
       {'template': 'registration/invitation_complete.html'},
    url(r'^validate/complete/$', direct_to_template,
       {'template': 'registration/validation_complete.html'},
    # Validation keys get matched by \w+ instead of the more specific
    # [a-fA-F0-9]{40} because a bad activation key should still get to the view;
    # that way it can return a sensible "invalid key" message instead of a
    # confusing 404.
    url(r'^validate/(?P<validation_key>\w+)/$', activate,
       {'backend': 'registration.backends.invitational.InvitationBackend'},
    url(r'^register/$', register,
       {'backend': 'registration.backends.invitational.InvitationBackend'},
    url(r'^register/complete/$', direct_to_template,
       {'template': 'registration/registration_complete.html'},
    url(r'^register/closed/$', direct_to_template,
       {'template': 'registration/registration_closed.html'},
    (r'', include('registration.auth_urls')),