@@ -25,14 +25,14 @@ class TreeRegistrationForm(RegistrationForm):
25
25
required = False )
26
26
zip_code = PostalCodeField (required = False )
27
27
photo = forms .ImageField (required = False )
28
-
29
-
28
+
29
+
30
30
class TreeBackend (DefaultBackend ):
31
31
32
32
def get_form_class (self , request ):
33
33
return TreeRegistrationForm
34
-
35
- # also possible to catch signal to allow not having to
34
+
35
+ # also possible to catch signal to allow not having to
36
36
# mix profiles app and registration app
37
37
# http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
38
38
# but since we are already extending registration
@@ -53,136 +53,3 @@ def register(self, request, **kwargs):
53
53
profile .photo = kwargs .get ('photo' )
54
54
profile .save ()
55
55
return new_user
56
-
57
- # here just for quick reference, not being used...
58
-
59
- class _DefaultBackend (object ):
60
- """
61
- A registration backend which follows a simple workflow:
62
-
63
- 1. User signs up, inactive account is created.
64
-
65
- 2. Email is sent to user with activation link.
66
-
67
- 3. User clicks activation link, account is now active.
68
-
69
- Using this backend requires that
70
-
71
- * ``registration`` be listed in the ``INSTALLED_APPS`` setting
72
- (since this backend makes use of models defined in this
73
- application).
74
-
75
- * The setting ``ACCOUNT_ACTIVATION_DAYS`` be supplied, specifying
76
- (as an integer) the number of days from registration during
77
- which a user may activate their account (after that period
78
- expires, activation will be disallowed).
79
-
80
- * The creation of the templates
81
- ``registration/activation_email_subject.txt`` and
82
- ``registration/activation_email.txt``, which will be used for
83
- the activation email. See the notes for this backends
84
- ``register`` method for details regarding these templates.
85
-
86
- Additionally, registration can be temporarily closed by adding the
87
- setting ``REGISTRATION_OPEN`` and setting it to
88
- ``False``. Omitting this setting, or setting it to ``True``, will
89
- be interpreted as meaning that registration is currently open and
90
- permitted.
91
-
92
- Internally, this is accomplished via storing an activation key in
93
- an instance of ``registration.models.RegistrationProfile``. See
94
- that model and its custom manager for full documentation of its
95
- fields and supported operations.
96
-
97
- """
98
- def register (self , request , ** kwargs ):
99
- """
100
- Given a username, email address and password, register a new
101
- user account, which will initially be inactive.
102
-
103
- Along with the new ``User`` object, a new
104
- ``registration.models.RegistrationProfile`` will be created,
105
- tied to that ``User``, containing the activation key which
106
- will be used for this account.
107
-
108
- An email will be sent to the supplied email address; this
109
- email should contain an activation link. The email will be
110
- rendered using two templates. See the documentation for
111
- ``RegistrationProfile.send_activation_email()`` for
112
- information about these templates and the contexts provided to
113
- them.
114
-
115
- After the ``User`` and ``RegistrationProfile`` are created and
116
- the activation email is sent, the signal
117
- ``registration.signals.user_registered`` will be sent, with
118
- the new ``User`` as the keyword argument ``user`` and the
119
- class of this backend as the sender.
120
-
121
- """
122
- username , email , password = kwargs ['username' ], kwargs ['email' ], kwargs ['password1' ]
123
- if Site ._meta .installed :
124
- site = Site .objects .get_current ()
125
- else :
126
- site = RequestSite (request )
127
- new_user = RegistrationProfile .objects .create_inactive_user (username , email ,
128
- password , site )
129
- signals .user_registered .send (sender = self .__class__ ,
130
- user = new_user ,
131
- request = request )
132
- return new_user
133
-
134
- def activate (self , request , activation_key ):
135
- """
136
- Given an an activation key, look up and activate the user
137
- account corresponding to that key (if possible).
138
-
139
- After successful activation, the signal
140
- ``registration.signals.user_activated`` will be sent, with the
141
- newly activated ``User`` as the keyword argument ``user`` and
142
- the class of this backend as the sender.
143
-
144
- """
145
- activated = RegistrationProfile .objects .activate_user (activation_key )
146
- if activated :
147
- signals .user_activated .send (sender = self .__class__ ,
148
- user = activated ,
149
- request = request )
150
- return activated
151
-
152
- def registration_allowed (self , request ):
153
- """
154
- Indicate whether account registration is currently permitted,
155
- based on the value of the setting ``REGISTRATION_OPEN``. This
156
- is determined as follows:
157
-
158
- * If ``REGISTRATION_OPEN`` is not specified in settings, or is
159
- set to ``True``, registration is permitted.
160
-
161
- * If ``REGISTRATION_OPEN`` is both specified and set to
162
- ``False``, registration is not permitted.
163
-
164
- """
165
- return getattr (settings , 'REGISTRATION_OPEN' , True )
166
-
167
- def get_form_class (self , request ):
168
- """
169
- Return the default form class used for user registration.
170
-
171
- """
172
- return RegistrationForm
173
-
174
- def post_registration_redirect (self , request , user ):
175
- """
176
- Return the name of the URL to redirect to after successful
177
- user registration.
178
-
179
- """
180
- return ('registration_complete' , (), {})
181
-
182
- def post_activation_redirect (self , request , user ):
183
- """
184
- Return the name of the URL to redirect to after successful
185
- account activation.
186
-
187
- """
188
- return ('registration_activation_complete' , (), {})
0 commit comments