root / snf-astakos-app / astakos / im / forms.py @ e7cb4085
History | View | Annotate | Download (41.2 kB)
1 |
# Copyright 2011-2012 GRNET S.A. All rights reserved.
|
---|---|
2 |
#
|
3 |
# Redistribution and use in source and binary forms, with or
|
4 |
# without modification, are permitted provided that the following
|
5 |
# conditions are met:
|
6 |
#
|
7 |
# 1. Redistributions of source code must retain the above
|
8 |
# copyright notice, this list of conditions and the following
|
9 |
# disclaimer.
|
10 |
#
|
11 |
# 2. Redistributions in binary form must reproduce the above
|
12 |
# copyright notice, this list of conditions and the following
|
13 |
# disclaimer in the documentation and/or other materials
|
14 |
# provided with the distribution.
|
15 |
#
|
16 |
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 |
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 |
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 |
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 |
# POSSIBILITY OF SUCH DAMAGE.
|
28 |
#
|
29 |
# The views and conclusions contained in the software and
|
30 |
# documentation are those of the authors and should not be
|
31 |
# interpreted as representing official policies, either expressed
|
32 |
# or implied, of GRNET S.A.
|
33 |
from random import random |
34 |
from datetime import datetime, timedelta |
35 |
|
36 |
from django import forms |
37 |
from django.utils.translation import ugettext as _ |
38 |
from django.contrib.auth.forms import ( |
39 |
UserCreationForm, AuthenticationForm, |
40 |
PasswordResetForm, PasswordChangeForm, |
41 |
SetPasswordForm) |
42 |
from django.core.mail import send_mail, get_connection |
43 |
from django.contrib.auth.tokens import default_token_generator |
44 |
from django.template import Context, loader |
45 |
from django.utils.http import int_to_base36 |
46 |
from django.core.urlresolvers import reverse |
47 |
from django.utils.safestring import mark_safe |
48 |
from django.utils.encoding import smart_str |
49 |
from django.conf import settings |
50 |
from django.forms.models import fields_for_model |
51 |
from django.db import transaction |
52 |
from django.utils.encoding import smart_unicode |
53 |
from django.core import validators |
54 |
from django.contrib.auth.models import AnonymousUser |
55 |
from django.core.exceptions import PermissionDenied |
56 |
|
57 |
from synnefo.lib import join_urls |
58 |
from astakos.im.models import ( |
59 |
AstakosUser, EmailChange, Invitation, |
60 |
Resource, PendingThirdPartyUser, get_latest_terms, |
61 |
ProjectApplication, Project) |
62 |
from astakos.im.settings import ( |
63 |
INVITATIONS_PER_LEVEL, BASEURL, SITENAME, RECAPTCHA_PRIVATE_KEY, |
64 |
RECAPTCHA_ENABLED, CONTACT_EMAIL, LOGGING_LEVEL, |
65 |
PASSWORD_RESET_EMAIL_SUBJECT, NEWPASSWD_INVALIDATE_TOKEN, |
66 |
MODERATION_ENABLED, EMAILCHANGE_ENABLED, |
67 |
) |
68 |
from astakos.im import presentation |
69 |
from astakos.im.widgets import DummyWidget, RecaptchaWidget |
70 |
from astakos.im.functions import ( |
71 |
send_change_email, submit_application, accept_membership_checks) |
72 |
|
73 |
from astakos.im.util import reserved_email, reserved_verified_email, \ |
74 |
get_query, model_to_dict |
75 |
from astakos.im import auth_providers |
76 |
|
77 |
import astakos.im.messages as astakos_messages |
78 |
|
79 |
import logging |
80 |
import hashlib |
81 |
import recaptcha.client.captcha as captcha |
82 |
import re |
83 |
|
84 |
logger = logging.getLogger(__name__) |
85 |
|
86 |
DOMAIN_VALUE_REGEX = re.compile( |
87 |
r'^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$',
|
88 |
re.IGNORECASE) |
89 |
|
90 |
|
91 |
class StoreUserMixin(object): |
92 |
|
93 |
def store_user(self, user, request=None): |
94 |
"""
|
95 |
WARNING: this should be wrapped inside a transactional view/method.
|
96 |
"""
|
97 |
user.save() |
98 |
self.post_store_user(user, request)
|
99 |
return user
|
100 |
|
101 |
def post_store_user(self, user, request): |
102 |
"""
|
103 |
Interface method for descendant backends to be able to do stuff within
|
104 |
the transaction enabled by store_user.
|
105 |
"""
|
106 |
pass
|
107 |
|
108 |
|
109 |
class LocalUserCreationForm(UserCreationForm, StoreUserMixin): |
110 |
"""
|
111 |
Extends the built in UserCreationForm in several ways:
|
112 |
|
113 |
* Adds email, first_name, last_name, recaptcha_challenge_field,
|
114 |
* recaptcha_response_field field.
|
115 |
* The username field isn't visible and it is assigned a generated id.
|
116 |
* User created is not active.
|
117 |
"""
|
118 |
recaptcha_challenge_field = forms.CharField(widget=DummyWidget) |
119 |
recaptcha_response_field = forms.CharField( |
120 |
widget=RecaptchaWidget, label='')
|
121 |
|
122 |
class Meta: |
123 |
model = AstakosUser |
124 |
fields = ("email", "first_name", "last_name", |
125 |
"has_signed_terms", "has_signed_terms") |
126 |
|
127 |
def __init__(self, *args, **kwargs): |
128 |
"""
|
129 |
Changes the order of fields, and removes the username field.
|
130 |
"""
|
131 |
request = kwargs.pop('request', None) |
132 |
provider = kwargs.pop('provider', 'local') |
133 |
|
134 |
# we only use LocalUserCreationForm for local provider
|
135 |
if not provider == 'local': |
136 |
raise Exception('Invalid provider') |
137 |
|
138 |
if request:
|
139 |
self.ip = request.META.get('REMOTE_ADDR', |
140 |
request.META.get('HTTP_X_REAL_IP',
|
141 |
None))
|
142 |
|
143 |
super(LocalUserCreationForm, self).__init__(*args, **kwargs) |
144 |
self.fields.keyOrder = ['email', 'first_name', 'last_name', |
145 |
'password1', 'password2'] |
146 |
|
147 |
if RECAPTCHA_ENABLED:
|
148 |
self.fields.keyOrder.extend(['recaptcha_challenge_field', |
149 |
'recaptcha_response_field', ])
|
150 |
if get_latest_terms():
|
151 |
self.fields.keyOrder.append('has_signed_terms') |
152 |
|
153 |
if 'has_signed_terms' in self.fields: |
154 |
# Overriding field label since we need to apply a link
|
155 |
# to the terms within the label
|
156 |
terms_link_html = '<a href="%s" target="_blank">%s</a>' \
|
157 |
% (reverse('latest_terms'), _("the terms")) |
158 |
self.fields['has_signed_terms'].label = \ |
159 |
mark_safe("I agree with %s" % terms_link_html)
|
160 |
|
161 |
def clean_email(self): |
162 |
email = self.cleaned_data['email'] |
163 |
if not email: |
164 |
raise forms.ValidationError(_(astakos_messages.REQUIRED_FIELD))
|
165 |
if reserved_verified_email(email):
|
166 |
raise forms.ValidationError(_(astakos_messages.EMAIL_USED))
|
167 |
return email
|
168 |
|
169 |
def clean_has_signed_terms(self): |
170 |
has_signed_terms = self.cleaned_data['has_signed_terms'] |
171 |
if not has_signed_terms: |
172 |
raise forms.ValidationError(_(astakos_messages.SIGN_TERMS))
|
173 |
return has_signed_terms
|
174 |
|
175 |
def clean_recaptcha_response_field(self): |
176 |
if 'recaptcha_challenge_field' in self.cleaned_data: |
177 |
self.validate_captcha()
|
178 |
return self.cleaned_data['recaptcha_response_field'] |
179 |
|
180 |
def clean_recaptcha_challenge_field(self): |
181 |
if 'recaptcha_response_field' in self.cleaned_data: |
182 |
self.validate_captcha()
|
183 |
return self.cleaned_data['recaptcha_challenge_field'] |
184 |
|
185 |
def validate_captcha(self): |
186 |
rcf = self.cleaned_data['recaptcha_challenge_field'] |
187 |
rrf = self.cleaned_data['recaptcha_response_field'] |
188 |
check = captcha.submit(rcf, rrf, RECAPTCHA_PRIVATE_KEY, self.ip)
|
189 |
if not check.is_valid: |
190 |
raise forms.ValidationError(_(astakos_messages.CAPTCHA_VALIDATION_ERR))
|
191 |
|
192 |
def post_store_user(self, user, request=None): |
193 |
"""
|
194 |
Interface method for descendant backends to be able to do stuff within
|
195 |
the transaction enabled by store_user.
|
196 |
"""
|
197 |
user.add_auth_provider('local', auth_backend='astakos') |
198 |
user.set_password(self.cleaned_data['password1']) |
199 |
|
200 |
def save(self, commit=True): |
201 |
"""
|
202 |
Saves the email, first_name and last_name properties, after the normal
|
203 |
save behavior is complete.
|
204 |
"""
|
205 |
user = super(LocalUserCreationForm, self).save(commit=False) |
206 |
user.date_signed_terms = datetime.now() |
207 |
user.renew_token() |
208 |
if commit:
|
209 |
user.save() |
210 |
logger.info('Created user %s', user.log_display)
|
211 |
return user
|
212 |
|
213 |
|
214 |
class InvitedLocalUserCreationForm(LocalUserCreationForm): |
215 |
"""
|
216 |
Extends the LocalUserCreationForm: email is readonly.
|
217 |
"""
|
218 |
class Meta: |
219 |
model = AstakosUser |
220 |
fields = ("email", "first_name", "last_name", "has_signed_terms") |
221 |
|
222 |
def __init__(self, *args, **kwargs): |
223 |
"""
|
224 |
Changes the order of fields, and removes the username field.
|
225 |
"""
|
226 |
super(InvitedLocalUserCreationForm, self).__init__(*args, **kwargs) |
227 |
|
228 |
#set readonly form fields
|
229 |
ro = ('email', 'username',) |
230 |
for f in ro: |
231 |
self.fields[f].widget.attrs['readonly'] = True |
232 |
|
233 |
def save(self, commit=True): |
234 |
user = super(InvitedLocalUserCreationForm, self).save(commit=False) |
235 |
user.set_invitations_level() |
236 |
user.email_verified = True
|
237 |
if commit:
|
238 |
user.save() |
239 |
return user
|
240 |
|
241 |
|
242 |
class ThirdPartyUserCreationForm(forms.ModelForm, StoreUserMixin): |
243 |
email = forms.EmailField( |
244 |
label='Contact email',
|
245 |
help_text='This is needed for contact purposes. '
|
246 |
'It doesn't need to be the same with the one you '
|
247 |
'provided to login previously. '
|
248 |
) |
249 |
|
250 |
class Meta: |
251 |
model = AstakosUser |
252 |
fields = ['email', 'first_name', 'last_name', 'has_signed_terms'] |
253 |
|
254 |
def __init__(self, *args, **kwargs): |
255 |
"""
|
256 |
Changes the order of fields, and removes the username field.
|
257 |
"""
|
258 |
|
259 |
self.provider = kwargs.pop('provider', None) |
260 |
if not self.provider or self.provider == 'local': |
261 |
raise Exception('Invalid provider, %r' % self.provider) |
262 |
|
263 |
# ThirdPartyUserCreationForm should always get instantiated with
|
264 |
# a third_party_token value
|
265 |
self.third_party_token = kwargs.pop('third_party_token', None) |
266 |
if not self.third_party_token: |
267 |
raise Exception('ThirdPartyUserCreationForm' |
268 |
' requires third_party_token')
|
269 |
|
270 |
super(ThirdPartyUserCreationForm, self).__init__(*args, **kwargs) |
271 |
|
272 |
if not get_latest_terms(): |
273 |
del self.fields['has_signed_terms'] |
274 |
|
275 |
if 'has_signed_terms' in self.fields: |
276 |
# Overriding field label since we need to apply a link
|
277 |
# to the terms within the label
|
278 |
terms_link_html = '<a href="%s" target="_blank">%s</a>' \
|
279 |
% (reverse('latest_terms'), _("the terms")) |
280 |
self.fields['has_signed_terms'].label = \ |
281 |
mark_safe("I agree with %s" % terms_link_html)
|
282 |
|
283 |
def clean_email(self): |
284 |
email = self.cleaned_data['email'] |
285 |
if not email: |
286 |
raise forms.ValidationError(_(astakos_messages.REQUIRED_FIELD))
|
287 |
if reserved_verified_email(email):
|
288 |
provider_id = self.provider
|
289 |
provider = auth_providers.get_provider(provider_id) |
290 |
extra_message = provider.get_add_to_existing_account_msg |
291 |
|
292 |
raise forms.ValidationError(mark_safe(
|
293 |
_(astakos_messages.EMAIL_USED) + ' ' + extra_message))
|
294 |
return email
|
295 |
|
296 |
def clean_has_signed_terms(self): |
297 |
has_signed_terms = self.cleaned_data['has_signed_terms'] |
298 |
if not has_signed_terms: |
299 |
raise forms.ValidationError(_(astakos_messages.SIGN_TERMS))
|
300 |
return has_signed_terms
|
301 |
|
302 |
def _get_pending_user(self): |
303 |
return PendingThirdPartyUser.objects.get(token=self.third_party_token) |
304 |
|
305 |
def post_store_user(self, user, request=None): |
306 |
pending = self._get_pending_user()
|
307 |
provider = pending.get_provider(user) |
308 |
provider.add_to_user() |
309 |
pending.delete() |
310 |
|
311 |
def save(self, commit=True): |
312 |
user = super(ThirdPartyUserCreationForm, self).save(commit=False) |
313 |
user.set_unusable_password() |
314 |
user.renew_token() |
315 |
user.date_signed_terms = datetime.now() |
316 |
if commit:
|
317 |
user.save() |
318 |
logger.info('Created user %s' % user.log_display)
|
319 |
return user
|
320 |
|
321 |
|
322 |
class InvitedThirdPartyUserCreationForm(ThirdPartyUserCreationForm): |
323 |
"""
|
324 |
Extends the ThirdPartyUserCreationForm: email is readonly.
|
325 |
"""
|
326 |
def __init__(self, *args, **kwargs): |
327 |
"""
|
328 |
Changes the order of fields, and removes the username field.
|
329 |
"""
|
330 |
super(
|
331 |
InvitedThirdPartyUserCreationForm, self).__init__(*args, **kwargs)
|
332 |
|
333 |
#set readonly form fields
|
334 |
ro = ('email',)
|
335 |
for f in ro: |
336 |
self.fields[f].widget.attrs['readonly'] = True |
337 |
|
338 |
def save(self, commit=True): |
339 |
user = super(InvitedThirdPartyUserCreationForm, self).save(commit=False) |
340 |
user.set_invitation_level() |
341 |
user.email_verified = True
|
342 |
if commit:
|
343 |
user.save() |
344 |
return user
|
345 |
|
346 |
|
347 |
class ShibbolethUserCreationForm(ThirdPartyUserCreationForm): |
348 |
additional_email = forms.CharField( |
349 |
widget=forms.HiddenInput(), label='', required=False) |
350 |
|
351 |
def __init__(self, *args, **kwargs): |
352 |
super(ShibbolethUserCreationForm, self).__init__(*args, **kwargs) |
353 |
# copy email value to additional_mail in case user will change it
|
354 |
name = 'email'
|
355 |
field = self.fields[name]
|
356 |
self.initial['additional_email'] = self.initial.get(name, field.initial) |
357 |
self.initial['email'] = None |
358 |
|
359 |
|
360 |
class InvitedShibbolethUserCreationForm(ShibbolethUserCreationForm, |
361 |
InvitedThirdPartyUserCreationForm): |
362 |
pass
|
363 |
|
364 |
|
365 |
class LoginForm(AuthenticationForm): |
366 |
username = forms.EmailField(label=_("Email"))
|
367 |
recaptcha_challenge_field = forms.CharField(widget=DummyWidget) |
368 |
recaptcha_response_field = forms.CharField( |
369 |
widget=RecaptchaWidget, label='')
|
370 |
|
371 |
def __init__(self, *args, **kwargs): |
372 |
was_limited = kwargs.get('was_limited', False) |
373 |
request = kwargs.get('request', None) |
374 |
if request:
|
375 |
self.ip = request.META.get('REMOTE_ADDR', |
376 |
request.META.get('HTTP_X_REAL_IP', None)) |
377 |
|
378 |
t = ('request', 'was_limited') |
379 |
for elem in t: |
380 |
if elem in kwargs.keys(): |
381 |
kwargs.pop(elem) |
382 |
super(LoginForm, self).__init__(*args, **kwargs) |
383 |
|
384 |
self.fields.keyOrder = ['username', 'password'] |
385 |
if was_limited and RECAPTCHA_ENABLED: |
386 |
self.fields.keyOrder.extend(['recaptcha_challenge_field', |
387 |
'recaptcha_response_field', ])
|
388 |
|
389 |
def clean_username(self): |
390 |
return self.cleaned_data['username'].lower() |
391 |
|
392 |
def clean_recaptcha_response_field(self): |
393 |
if 'recaptcha_challenge_field' in self.cleaned_data: |
394 |
self.validate_captcha()
|
395 |
return self.cleaned_data['recaptcha_response_field'] |
396 |
|
397 |
def clean_recaptcha_challenge_field(self): |
398 |
if 'recaptcha_response_field' in self.cleaned_data: |
399 |
self.validate_captcha()
|
400 |
return self.cleaned_data['recaptcha_challenge_field'] |
401 |
|
402 |
def validate_captcha(self): |
403 |
rcf = self.cleaned_data['recaptcha_challenge_field'] |
404 |
rrf = self.cleaned_data['recaptcha_response_field'] |
405 |
check = captcha.submit(rcf, rrf, RECAPTCHA_PRIVATE_KEY, self.ip)
|
406 |
if not check.is_valid: |
407 |
raise forms.ValidationError(_(astakos_messages.CAPTCHA_VALIDATION_ERR))
|
408 |
|
409 |
def clean(self): |
410 |
"""
|
411 |
Override default behavior in order to check user's activation later
|
412 |
"""
|
413 |
username = self.cleaned_data.get('username') |
414 |
|
415 |
if username:
|
416 |
try:
|
417 |
user = AstakosUser.objects.get_by_identifier(username) |
418 |
if not user.has_auth_provider('local'): |
419 |
provider = auth_providers.get_provider('local', user)
|
420 |
msg = provider.get_login_disabled_msg |
421 |
raise forms.ValidationError(mark_safe(msg))
|
422 |
except AstakosUser.DoesNotExist:
|
423 |
pass
|
424 |
|
425 |
try:
|
426 |
super(LoginForm, self).clean() |
427 |
except forms.ValidationError, e:
|
428 |
if self.user_cache is None: |
429 |
raise
|
430 |
if not self.user_cache.is_active: |
431 |
msg = self.user_cache.get_inactive_message('local') |
432 |
raise forms.ValidationError(msg)
|
433 |
if self.request: |
434 |
if not self.request.session.test_cookie_worked(): |
435 |
raise
|
436 |
return self.cleaned_data |
437 |
|
438 |
|
439 |
class ProfileForm(forms.ModelForm): |
440 |
"""
|
441 |
Subclass of ``ModelForm`` for permiting user to edit his/her profile.
|
442 |
Most of the fields are readonly since the user is not allowed to change
|
443 |
them.
|
444 |
|
445 |
The class defines a save method which sets ``is_verified`` to True so as the
|
446 |
user during the next login will not to be redirected to profile page.
|
447 |
"""
|
448 |
email = forms.EmailField(label='E-mail address', help_text='E-mail address') |
449 |
renew = forms.BooleanField(label='Renew token', required=False) |
450 |
uuid = forms.CharField(label='User id', required=False) |
451 |
|
452 |
class Meta: |
453 |
model = AstakosUser |
454 |
fields = ('email', 'first_name', 'last_name', 'auth_token', |
455 |
'auth_token_expires', 'uuid') |
456 |
|
457 |
def __init__(self, *args, **kwargs): |
458 |
self.session_key = kwargs.pop('session_key', None) |
459 |
super(ProfileForm, self).__init__(*args, **kwargs) |
460 |
instance = getattr(self, 'instance', None) |
461 |
ro_fields = ('email', 'auth_token', 'auth_token_expires', 'uuid') |
462 |
if instance and instance.id: |
463 |
for field in ro_fields: |
464 |
self.fields[field].widget.attrs['readonly'] = True |
465 |
|
466 |
def clean_email(self): |
467 |
return self.instance.email |
468 |
|
469 |
def clean_auth_token(self): |
470 |
return self.instance.auth_token |
471 |
|
472 |
def clean_auth_token_expires(self): |
473 |
return self.instance.auth_token_expires |
474 |
|
475 |
def clean_uuid(self): |
476 |
return self.instance.uuid |
477 |
|
478 |
def save(self, commit=True): |
479 |
user = super(ProfileForm, self).save(commit=False) |
480 |
user.is_verified = True
|
481 |
if self.cleaned_data.get('renew'): |
482 |
user.renew_token( |
483 |
flush_sessions=True,
|
484 |
current_key=self.session_key
|
485 |
) |
486 |
if commit:
|
487 |
user.save() |
488 |
return user
|
489 |
|
490 |
|
491 |
|
492 |
class FeedbackForm(forms.Form): |
493 |
"""
|
494 |
Form for writing feedback.
|
495 |
"""
|
496 |
feedback_msg = forms.CharField(widget=forms.Textarea, label=u'Message')
|
497 |
feedback_data = forms.CharField(widget=forms.HiddenInput(), label='',
|
498 |
required=False)
|
499 |
|
500 |
|
501 |
class SendInvitationForm(forms.Form): |
502 |
"""
|
503 |
Form for sending an invitations
|
504 |
"""
|
505 |
|
506 |
email = forms.EmailField(required=True, label='Email address') |
507 |
first_name = forms.EmailField(label='First name')
|
508 |
last_name = forms.EmailField(label='Last name')
|
509 |
|
510 |
|
511 |
class ExtendedPasswordResetForm(PasswordResetForm): |
512 |
"""
|
513 |
Extends PasswordResetForm by overriding
|
514 |
|
515 |
save method: to pass a custom from_email in send_mail.
|
516 |
clean_email: to handle local auth provider checks
|
517 |
"""
|
518 |
def clean_email(self): |
519 |
# we override the default django auth clean_email to provide more
|
520 |
# detailed messages in case of inactive users
|
521 |
email = self.cleaned_data['email'] |
522 |
try:
|
523 |
user = AstakosUser.objects.get_by_identifier(email) |
524 |
self.users_cache = [user]
|
525 |
if not user.is_active: |
526 |
msg = mark_safe(user.get_inactive_message('local'))
|
527 |
raise forms.ValidationError(msg)
|
528 |
|
529 |
provider = auth_providers.get_provider('local', user)
|
530 |
if not user.has_usable_password(): |
531 |
msg = provider.get_unusable_password_msg |
532 |
raise forms.ValidationError(mark_safe(msg))
|
533 |
|
534 |
if not user.can_change_password(): |
535 |
msg = provider.get_cannot_change_password_msg |
536 |
raise forms.ValidationError(mark_safe(msg))
|
537 |
|
538 |
except AstakosUser.DoesNotExist:
|
539 |
raise forms.ValidationError(_(astakos_messages.EMAIL_UNKNOWN))
|
540 |
return email
|
541 |
|
542 |
def save( |
543 |
self, domain_override=None, email_template_name='registration/password_reset_email.html', |
544 |
use_https=False, token_generator=default_token_generator, request=None): |
545 |
"""
|
546 |
Generates a one-use only link for resetting password and sends to the user.
|
547 |
"""
|
548 |
for user in self.users_cache: |
549 |
url = user.astakosuser.get_password_reset_url(token_generator) |
550 |
url = join_urls(BASEURL, url) |
551 |
t = loader.get_template(email_template_name) |
552 |
c = { |
553 |
'email': user.email,
|
554 |
'url': url,
|
555 |
'site_name': SITENAME,
|
556 |
'user': user,
|
557 |
'baseurl': BASEURL,
|
558 |
'support': CONTACT_EMAIL
|
559 |
} |
560 |
from_email = settings.SERVER_EMAIL |
561 |
send_mail(_(PASSWORD_RESET_EMAIL_SUBJECT), |
562 |
t.render(Context(c)), |
563 |
from_email, |
564 |
[user.email], |
565 |
connection=get_connection()) |
566 |
|
567 |
|
568 |
class EmailChangeForm(forms.ModelForm): |
569 |
|
570 |
class Meta: |
571 |
model = EmailChange |
572 |
fields = ('new_email_address',)
|
573 |
|
574 |
def clean_new_email_address(self): |
575 |
addr = self.cleaned_data['new_email_address'] |
576 |
if reserved_verified_email(addr):
|
577 |
raise forms.ValidationError(_(astakos_messages.EMAIL_USED))
|
578 |
return addr
|
579 |
|
580 |
def save(self, request, email_template_name='registration/email_change_email.txt', commit=True): |
581 |
ec = super(EmailChangeForm, self).save(commit=False) |
582 |
ec.user = request.user |
583 |
# delete pending email changes
|
584 |
request.user.emailchanges.all().delete() |
585 |
|
586 |
activation_key = hashlib.sha1( |
587 |
str(random()) + smart_str(ec.new_email_address))
|
588 |
ec.activation_key = activation_key.hexdigest() |
589 |
if commit:
|
590 |
ec.save() |
591 |
send_change_email(ec, request, email_template_name=email_template_name) |
592 |
|
593 |
|
594 |
class SignApprovalTermsForm(forms.ModelForm): |
595 |
|
596 |
class Meta: |
597 |
model = AstakosUser |
598 |
fields = ("has_signed_terms",)
|
599 |
|
600 |
def __init__(self, *args, **kwargs): |
601 |
super(SignApprovalTermsForm, self).__init__(*args, **kwargs) |
602 |
|
603 |
def clean_has_signed_terms(self): |
604 |
has_signed_terms = self.cleaned_data['has_signed_terms'] |
605 |
if not has_signed_terms: |
606 |
raise forms.ValidationError(_(astakos_messages.SIGN_TERMS))
|
607 |
return has_signed_terms
|
608 |
|
609 |
def save(self, commit=True): |
610 |
user = super(SignApprovalTermsForm, self).save(commit) |
611 |
user.date_signed_terms = datetime.now() |
612 |
if commit:
|
613 |
user.save() |
614 |
return user
|
615 |
|
616 |
|
617 |
class InvitationForm(forms.ModelForm): |
618 |
|
619 |
username = forms.EmailField(label=_("Email"))
|
620 |
|
621 |
def __init__(self, *args, **kwargs): |
622 |
super(InvitationForm, self).__init__(*args, **kwargs) |
623 |
|
624 |
class Meta: |
625 |
model = Invitation |
626 |
fields = ('username', 'realname') |
627 |
|
628 |
def clean_username(self): |
629 |
username = self.cleaned_data['username'] |
630 |
try:
|
631 |
Invitation.objects.get(username=username) |
632 |
raise forms.ValidationError(_(astakos_messages.INVITATION_EMAIL_EXISTS))
|
633 |
except Invitation.DoesNotExist:
|
634 |
pass
|
635 |
return username
|
636 |
|
637 |
|
638 |
class ExtendedPasswordChangeForm(PasswordChangeForm): |
639 |
"""
|
640 |
Extends PasswordChangeForm by enabling user
|
641 |
to optionally renew also the token.
|
642 |
"""
|
643 |
if not NEWPASSWD_INVALIDATE_TOKEN: |
644 |
renew = forms.BooleanField(label='Renew token', required=False, |
645 |
initial=True,
|
646 |
help_text='Unsetting this may result in security risk.')
|
647 |
|
648 |
def __init__(self, user, *args, **kwargs): |
649 |
self.session_key = kwargs.pop('session_key', None) |
650 |
super(ExtendedPasswordChangeForm, self).__init__(user, *args, **kwargs) |
651 |
|
652 |
def save(self, commit=True): |
653 |
try:
|
654 |
if NEWPASSWD_INVALIDATE_TOKEN or self.cleaned_data.get('renew'): |
655 |
self.user.renew_token()
|
656 |
self.user.flush_sessions(current_key=self.session_key) |
657 |
except AttributeError: |
658 |
# if user model does has not such methods
|
659 |
pass
|
660 |
return super(ExtendedPasswordChangeForm, self).save(commit=commit) |
661 |
|
662 |
class ExtendedSetPasswordForm(SetPasswordForm): |
663 |
"""
|
664 |
Extends SetPasswordForm by enabling user
|
665 |
to optionally renew also the token.
|
666 |
"""
|
667 |
if not NEWPASSWD_INVALIDATE_TOKEN: |
668 |
renew = forms.BooleanField( |
669 |
label='Renew token',
|
670 |
required=False,
|
671 |
initial=True,
|
672 |
help_text='Unsetting this may result in security risk.')
|
673 |
|
674 |
def __init__(self, user, *args, **kwargs): |
675 |
super(ExtendedSetPasswordForm, self).__init__(user, *args, **kwargs) |
676 |
|
677 |
@transaction.commit_on_success()
|
678 |
def save(self, commit=True): |
679 |
try:
|
680 |
self.user = AstakosUser.objects.get(id=self.user.id) |
681 |
if NEWPASSWD_INVALIDATE_TOKEN or self.cleaned_data.get('renew'): |
682 |
self.user.renew_token()
|
683 |
|
684 |
provider = auth_providers.get_provider('local', self.user) |
685 |
if provider.get_add_policy:
|
686 |
provider.add_to_user() |
687 |
|
688 |
except BaseException, e: |
689 |
logger.exception(e) |
690 |
return super(ExtendedSetPasswordForm, self).save(commit=commit) |
691 |
|
692 |
|
693 |
|
694 |
|
695 |
app_name_label = "Project name"
|
696 |
app_name_placeholder = _("myproject.mylab.ntua.gr")
|
697 |
app_name_validator = validators.RegexValidator( |
698 |
DOMAIN_VALUE_REGEX, |
699 |
_(astakos_messages.DOMAIN_VALUE_ERR), |
700 |
'invalid')
|
701 |
app_name_help = _("""
|
702 |
The project's name should be in a domain format.
|
703 |
The domain shouldn't neccessarily exist in the real
|
704 |
world but is helpful to imply a structure.
|
705 |
e.g.: myproject.mylab.ntua.gr or
|
706 |
myservice.myteam.myorganization""")
|
707 |
app_name_widget = forms.TextInput( |
708 |
attrs={'placeholder': app_name_placeholder})
|
709 |
|
710 |
|
711 |
app_home_label = "Homepage URL"
|
712 |
app_home_placeholder = 'myinstitution.org/myproject/'
|
713 |
app_home_help = _("""
|
714 |
URL pointing at your project's site.
|
715 |
e.g.: myinstitution.org/myproject/.
|
716 |
Leave blank if there is no website.""")
|
717 |
app_home_widget = forms.TextInput( |
718 |
attrs={'placeholder': app_home_placeholder})
|
719 |
|
720 |
app_desc_label = _("Description")
|
721 |
app_desc_help = _("""
|
722 |
Please provide a short but descriptive abstract of your
|
723 |
project, so that anyone searching can quickly understand
|
724 |
what this project is about.""")
|
725 |
|
726 |
app_comment_label = _("Comments for review (private)")
|
727 |
app_comment_help = _("""
|
728 |
Write down any comments you may have for the reviewer
|
729 |
of this application (e.g. background and rationale to
|
730 |
support your request).
|
731 |
The comments are strictly for the review process
|
732 |
and will not be made public.""")
|
733 |
|
734 |
app_start_date_label = _("Start date")
|
735 |
app_start_date_help = _("""
|
736 |
Provide a date when your need your project to be created,
|
737 |
and members to be able to join and get resources.
|
738 |
This date is only a hint to help prioritize reviews.""")
|
739 |
|
740 |
app_end_date_label = _("Termination date")
|
741 |
app_end_date_help = _("""
|
742 |
At this date, the project will be automatically terminated
|
743 |
and its resource grants revoked from all members. If you are
|
744 |
not certain, it is best to start with a conservative estimation.
|
745 |
You can always re-apply for an extension, if you need.""")
|
746 |
|
747 |
join_policy_label = _("Joining policy")
|
748 |
app_member_join_policy_help = _("""
|
749 |
Select how new members are accepted into the project.""")
|
750 |
leave_policy_label = _("Leaving policy")
|
751 |
app_member_leave_policy_help = _("""
|
752 |
Select how new members can leave the project.""")
|
753 |
|
754 |
max_members_label = _("Maximum member count")
|
755 |
max_members_help = _("""
|
756 |
Specify the maximum number of members this project may have,
|
757 |
including the owner. Beyond this number, no new members
|
758 |
may join the project and be granted the project resources.
|
759 |
If you are not certain, it is best to start with a conservative
|
760 |
limit. You can always request a raise when you need it.""")
|
761 |
|
762 |
join_policies = presentation.PROJECT_MEMBER_JOIN_POLICIES.items() |
763 |
leave_policies = presentation.PROJECT_MEMBER_LEAVE_POLICIES.items() |
764 |
|
765 |
class ProjectApplicationForm(forms.ModelForm): |
766 |
|
767 |
name = forms.CharField( |
768 |
label = app_name_label, |
769 |
help_text = app_name_help, |
770 |
widget = app_name_widget, |
771 |
validators = [app_name_validator]) |
772 |
|
773 |
homepage = forms.URLField( |
774 |
label = app_home_label, |
775 |
help_text = app_home_help, |
776 |
widget = app_home_widget, |
777 |
required = False)
|
778 |
|
779 |
description = forms.CharField( |
780 |
label = app_desc_label, |
781 |
help_text = app_desc_help, |
782 |
widget = forms.Textarea, |
783 |
required = False)
|
784 |
|
785 |
comments = forms.CharField( |
786 |
label = app_comment_label, |
787 |
help_text = app_comment_help, |
788 |
widget = forms.Textarea, |
789 |
required = False)
|
790 |
|
791 |
start_date = forms.DateTimeField( |
792 |
label = app_start_date_label, |
793 |
help_text = app_start_date_help, |
794 |
required = False)
|
795 |
|
796 |
end_date = forms.DateTimeField( |
797 |
label = app_end_date_label, |
798 |
help_text = app_end_date_help) |
799 |
|
800 |
member_join_policy = forms.TypedChoiceField( |
801 |
label = join_policy_label, |
802 |
help_text = app_member_join_policy_help, |
803 |
initial = 2,
|
804 |
coerce = int,
|
805 |
choices = join_policies) |
806 |
|
807 |
member_leave_policy = forms.TypedChoiceField( |
808 |
label = leave_policy_label, |
809 |
help_text = app_member_leave_policy_help, |
810 |
coerce = int,
|
811 |
choices = leave_policies) |
812 |
|
813 |
limit_on_members_number = forms.IntegerField( |
814 |
label = max_members_label, |
815 |
help_text = max_members_help, |
816 |
min_value = 0,
|
817 |
required = False)
|
818 |
|
819 |
class Meta: |
820 |
model = ProjectApplication |
821 |
fields = ( 'name', 'homepage', 'description', |
822 |
'start_date', 'end_date', 'comments', |
823 |
'member_join_policy', 'member_leave_policy', |
824 |
'limit_on_members_number')
|
825 |
|
826 |
def __init__(self, *args, **kwargs): |
827 |
instance = kwargs.get('instance')
|
828 |
self.precursor_application = instance
|
829 |
super(ProjectApplicationForm, self).__init__(*args, **kwargs) |
830 |
# in case of new application remove closed join policy
|
831 |
if not instance: |
832 |
policies = presentation.PROJECT_MEMBER_JOIN_POLICIES.copy() |
833 |
policies.pop(3)
|
834 |
self.fields['member_join_policy'].choices = policies.iteritems() |
835 |
|
836 |
def clean_start_date(self): |
837 |
start_date = self.cleaned_data.get('start_date') |
838 |
if not self.precursor_application: |
839 |
today = datetime.now() |
840 |
today = datetime(today.year, today.month, today.day) |
841 |
if start_date and (start_date - today).days < 0: |
842 |
raise forms.ValidationError(
|
843 |
_(astakos_messages.INVALID_PROJECT_START_DATE)) |
844 |
return start_date
|
845 |
|
846 |
def clean_end_date(self): |
847 |
start_date = self.cleaned_data.get('start_date') |
848 |
end_date = self.cleaned_data.get('end_date') |
849 |
today = datetime.now() |
850 |
today = datetime(today.year, today.month, today.day) |
851 |
if end_date and (end_date - today).days < 0: |
852 |
raise forms.ValidationError(
|
853 |
_(astakos_messages.INVALID_PROJECT_END_DATE)) |
854 |
if start_date and (end_date - start_date).days <= 0: |
855 |
raise forms.ValidationError(
|
856 |
_(astakos_messages.INCONSISTENT_PROJECT_DATES)) |
857 |
return end_date
|
858 |
|
859 |
def clean(self): |
860 |
userid = self.data.get('user', None) |
861 |
policies = self.resource_policies
|
862 |
self.user = None |
863 |
if userid:
|
864 |
try:
|
865 |
self.user = AstakosUser.objects.get(id=userid)
|
866 |
except AstakosUser.DoesNotExist:
|
867 |
pass
|
868 |
if not self.user: |
869 |
raise forms.ValidationError(_(astakos_messages.NO_APPLICANT))
|
870 |
super(ProjectApplicationForm, self).clean() |
871 |
return self.cleaned_data |
872 |
|
873 |
@property
|
874 |
def resource_policies(self): |
875 |
policies = [] |
876 |
append = policies.append |
877 |
for name, value in self.data.iteritems(): |
878 |
if not value: |
879 |
continue
|
880 |
uplimit = value |
881 |
if name.endswith('_uplimit'): |
882 |
subs = name.split('_uplimit')
|
883 |
prefix, suffix = subs |
884 |
try:
|
885 |
resource = Resource.objects.get(name=prefix) |
886 |
except Resource.DoesNotExist:
|
887 |
raise forms.ValidationError("Resource %s does not exist" % |
888 |
resource.name) |
889 |
# keep only resource limits for selected resource groups
|
890 |
if self.data.get( |
891 |
'is_selected_%s' % resource.group, "0" |
892 |
) == "1":
|
893 |
if not resource.allow_in_projects: |
894 |
raise forms.ValidationError("Invalid resource %s" % |
895 |
resource.name) |
896 |
d = model_to_dict(resource) |
897 |
if uplimit:
|
898 |
d.update(dict(resource=prefix, uplimit=uplimit))
|
899 |
else:
|
900 |
d.update(dict(resource=prefix, uplimit=None)) |
901 |
append(d) |
902 |
|
903 |
ordered_keys = presentation.RESOURCES['resources_order']
|
904 |
def resource_order(r): |
905 |
if r['str_repr'] in ordered_keys: |
906 |
return ordered_keys.index(r['str_repr']) |
907 |
else:
|
908 |
return -1 |
909 |
|
910 |
policies = sorted(policies, key=resource_order)
|
911 |
return policies
|
912 |
|
913 |
def cleaned_resource_policies(self): |
914 |
return [(d['name'], d['uplimit']) for d in self.resource_policies] |
915 |
|
916 |
def save(self, commit=True): |
917 |
data = dict(self.cleaned_data) |
918 |
data['precursor_id'] = self.instance.id |
919 |
is_new = self.instance.id is None |
920 |
data['owner'] = self.user if is_new else self.instance.owner |
921 |
data['resource_policies'] = self.cleaned_resource_policies() |
922 |
data['request_user'] = self.user |
923 |
submit_application(**data) |
924 |
|
925 |
|
926 |
class ProjectSortForm(forms.Form): |
927 |
sorting = forms.ChoiceField( |
928 |
label='Sort by',
|
929 |
choices=(('name', 'Sort by Name'), |
930 |
('issue_date', 'Sort by Issue date'), |
931 |
('start_date', 'Sort by Start Date'), |
932 |
('end_date', 'Sort by End Date'), |
933 |
# ('approved_members_num', 'Sort by Participants'),
|
934 |
('state', 'Sort by Status'), |
935 |
('member_join_policy__description', 'Sort by Member Join Policy'), |
936 |
('member_leave_policy__description', 'Sort by Member Leave Policy'), |
937 |
('-name', 'Sort by Name'), |
938 |
('-issue_date', 'Sort by Issue date'), |
939 |
('-start_date', 'Sort by Start Date'), |
940 |
('-end_date', 'Sort by End Date'), |
941 |
# ('-approved_members_num', 'Sort by Participants'),
|
942 |
('-state', 'Sort by Status'), |
943 |
('-member_join_policy__description', 'Sort by Member Join Policy'), |
944 |
('-member_leave_policy__description', 'Sort by Member Leave Policy') |
945 |
), |
946 |
required=True
|
947 |
) |
948 |
|
949 |
class AddProjectMembersForm(forms.Form): |
950 |
q = forms.CharField( |
951 |
max_length=800, widget=forms.Textarea, label=_('Add members'), |
952 |
help_text=_(astakos_messages.ADD_PROJECT_MEMBERS_Q_HELP), required=True)
|
953 |
|
954 |
def __init__(self, *args, **kwargs): |
955 |
chain_id = kwargs.pop('chain_id', None) |
956 |
if chain_id:
|
957 |
self.project = Project.objects.get(id=chain_id)
|
958 |
self.request_user = kwargs.pop('request_user', None) |
959 |
super(AddProjectMembersForm, self).__init__(*args, **kwargs) |
960 |
|
961 |
def clean(self): |
962 |
try:
|
963 |
accept_membership_checks(self.project, self.request_user) |
964 |
except PermissionDenied, e:
|
965 |
raise forms.ValidationError(e)
|
966 |
|
967 |
q = self.cleaned_data.get('q') or '' |
968 |
users = q.split(',')
|
969 |
users = list(u.strip() for u in users if u) |
970 |
db_entries = AstakosUser.objects.verified().filter(email__in=users) |
971 |
unknown = list(set(users) - set(u.email for u in db_entries)) |
972 |
if unknown:
|
973 |
raise forms.ValidationError(
|
974 |
_(astakos_messages.UNKNOWN_USERS) % ','.join(unknown))
|
975 |
self.valid_users = db_entries
|
976 |
return self.cleaned_data |
977 |
|
978 |
def get_valid_users(self): |
979 |
"""Should be called after form cleaning"""
|
980 |
try:
|
981 |
return self.valid_users |
982 |
except:
|
983 |
return ()
|
984 |
|
985 |
class ProjectMembersSortForm(forms.Form): |
986 |
sorting = forms.ChoiceField( |
987 |
label='Sort by',
|
988 |
choices=(('person__email', 'User Id'), |
989 |
('person__first_name', 'Name'), |
990 |
('acceptance_date', 'Acceptance date') |
991 |
), |
992 |
required=True
|
993 |
) |
994 |
|
995 |
|
996 |
class ProjectSearchForm(forms.Form): |
997 |
q = forms.CharField(max_length=200, label='Search project', required=False) |
998 |
|
999 |
|
1000 |
class ExtendedProfileForm(ProfileForm): |
1001 |
"""
|
1002 |
Profile form that combines `email change` and `password change` user
|
1003 |
actions by propagating submited data to internal EmailChangeForm
|
1004 |
and ExtendedPasswordChangeForm objects.
|
1005 |
"""
|
1006 |
|
1007 |
password_change_form = None
|
1008 |
email_change_form = None
|
1009 |
|
1010 |
password_change = False
|
1011 |
email_change = False
|
1012 |
|
1013 |
extra_forms_fields = { |
1014 |
'email': ['new_email_address'], |
1015 |
'password': ['old_password', 'new_password1', 'new_password2'] |
1016 |
} |
1017 |
|
1018 |
fields = ('email')
|
1019 |
change_password = forms.BooleanField(initial=False, required=False) |
1020 |
change_email = forms.BooleanField(initial=False, required=False) |
1021 |
|
1022 |
email_changed = False
|
1023 |
password_changed = False
|
1024 |
|
1025 |
def __init__(self, *args, **kwargs): |
1026 |
session_key = kwargs.get('session_key', None) |
1027 |
self.fields_list = [
|
1028 |
'email',
|
1029 |
'new_email_address',
|
1030 |
'first_name',
|
1031 |
'last_name',
|
1032 |
'auth_token',
|
1033 |
'auth_token_expires',
|
1034 |
'old_password',
|
1035 |
'new_password1',
|
1036 |
'new_password2',
|
1037 |
'change_email',
|
1038 |
'change_password',
|
1039 |
'uuid'
|
1040 |
] |
1041 |
|
1042 |
super(ExtendedProfileForm, self).__init__(*args, **kwargs) |
1043 |
self.session_key = session_key
|
1044 |
if self.instance.can_change_password(): |
1045 |
self.password_change = True |
1046 |
else:
|
1047 |
self.fields_list.remove('old_password') |
1048 |
self.fields_list.remove('new_password1') |
1049 |
self.fields_list.remove('new_password2') |
1050 |
self.fields_list.remove('change_password') |
1051 |
del self.fields['change_password'] |
1052 |
|
1053 |
if EMAILCHANGE_ENABLED and self.instance.can_change_email(): |
1054 |
self.email_change = True |
1055 |
else:
|
1056 |
self.fields_list.remove('new_email_address') |
1057 |
self.fields_list.remove('change_email') |
1058 |
del self.fields['change_email'] |
1059 |
|
1060 |
self._init_extra_forms()
|
1061 |
self.save_extra_forms = []
|
1062 |
self.success_messages = []
|
1063 |
self.fields.keyOrder = self.fields_list |
1064 |
|
1065 |
|
1066 |
def _init_extra_form_fields(self): |
1067 |
if self.email_change: |
1068 |
self.fields.update(self.email_change_form.fields) |
1069 |
self.fields['new_email_address'].required = False |
1070 |
self.fields['email'].help_text = _('Change the email associated with ' |
1071 |
'your account. This email will '
|
1072 |
'remain active until you verify '
|
1073 |
'your new one.')
|
1074 |
|
1075 |
if self.password_change: |
1076 |
self.fields.update(self.password_change_form.fields) |
1077 |
self.fields['old_password'].required = False |
1078 |
self.fields['old_password'].label = _('Password') |
1079 |
self.fields['old_password'].help_text = _('Change your password.') |
1080 |
self.fields['old_password'].initial = 'password' |
1081 |
self.fields['new_password1'].required = False |
1082 |
self.fields['new_password2'].required = False |
1083 |
|
1084 |
def _update_extra_form_errors(self): |
1085 |
if self.cleaned_data.get('change_password'): |
1086 |
self.errors.update(self.password_change_form.errors) |
1087 |
if self.cleaned_data.get('change_email'): |
1088 |
self.errors.update(self.email_change_form.errors) |
1089 |
|
1090 |
def _init_extra_forms(self): |
1091 |
self.email_change_form = EmailChangeForm(self.data) |
1092 |
self.password_change_form = ExtendedPasswordChangeForm(user=self.instance, |
1093 |
data=self.data, session_key=self.session_key) |
1094 |
self._init_extra_form_fields()
|
1095 |
|
1096 |
def is_valid(self): |
1097 |
password, email = True, True |
1098 |
profile = super(ExtendedProfileForm, self).is_valid() |
1099 |
if profile and self.cleaned_data.get('change_password', None): |
1100 |
|
1101 |
password = self.password_change_form.is_valid()
|
1102 |
self.save_extra_forms.append('password') |
1103 |
if profile and self.cleaned_data.get('change_email'): |
1104 |
self.fields['new_email_address'].required = True |
1105 |
email = self.email_change_form.is_valid()
|
1106 |
self.save_extra_forms.append('email') |
1107 |
|
1108 |
if not password or not email: |
1109 |
self._update_extra_form_errors()
|
1110 |
|
1111 |
return all([profile, password, email]) |
1112 |
|
1113 |
def save(self, request, *args, **kwargs): |
1114 |
if 'email' in self.save_extra_forms: |
1115 |
self.email_change_form.save(request, *args, **kwargs)
|
1116 |
self.email_changed = True |
1117 |
if 'password' in self.save_extra_forms: |
1118 |
self.password_change_form.save(*args, **kwargs)
|
1119 |
self.password_changed = True |
1120 |
return super(ExtendedProfileForm, self).save(*args, **kwargs) |
1121 |
|