-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding django-registration backend integration point.
- Loading branch information
Showing
4 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from registration.backends.default import DefaultBackend | ||
from .forms import RecaptchaRegistrationForm | ||
|
||
|
||
class RecaptchaBackend(DefaultBackend): | ||
def get_form_class(self, request): | ||
""" | ||
Return the recaptcha form class used for user registration. | ||
""" | ||
return RecaptchaRegistrationForm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from recaptcha_form.forms import RecaptchaForm | ||
from registration.forms import RegistrationForm | ||
|
||
|
||
class RecaptchaRegistrationForm(RecaptchaForm, RegistrationForm): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" | ||
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 activate | ||
from registration.views import register | ||
|
||
|
||
urlpatterns = patterns('', | ||
url(r'^activate/complete/$', | ||
direct_to_template, | ||
{'template': 'registration/activation_complete.html'}, | ||
name='registration_activation_complete'), | ||
# Activation 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'^activate/(?P<activation_key>\w+)/$', | ||
activate, | ||
{'backend': 'recaptcha_form.registration_backend.RecaptchaBackend'}, | ||
name='registration_activate'), | ||
url(r'^register/$', | ||
register, | ||
{'backend': 'recaptcha_form.registration_backend.RecaptchaBackend'}, | ||
name='registration_register'), | ||
url(r'^register/complete/$', | ||
direct_to_template, | ||
{'template': 'registration/registration_complete.html'}, | ||
name='registration_complete'), | ||
url(r'^register/closed/$', | ||
direct_to_template, | ||
{'template': 'registration/registration_closed.html'}, | ||
name='registration_disallowed'), | ||
(r'', include('registration.auth_urls')), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters