Commit 1bea338c authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

Fix a python syntax error

In python 2 we cannot have keyword-only arguments (PEP 3102).
And even if we could, this was not the right way to
declare a python function.
parent e722ea2e
......@@ -185,17 +185,16 @@ class LocalUserCreationForm(UserCreationForm, StoreUserMixin):
user.add_auth_provider('local', auth_backend='astakos')
user.set_password(self.cleaned_data['password1'])
def save(self, commit=True, *args, **kwargs):
def save(self, commit=True, **kwargs):
"""
Saves the email, first_name and last_name properties, after the normal
save behavior is complete.
"""
user = super(LocalUserCreationForm, self).save(commit=False,
*args, **kwargs)
user = super(LocalUserCreationForm, self).save(commit=False, **kwargs)
user.date_signed_terms = datetime.now()
user.renew_token()
if commit:
user.save(*args, **kwargs)
user.save(**kwargs)
logger.info('Created user %s', user.log_display)
return user
......@@ -219,13 +218,13 @@ class InvitedLocalUserCreationForm(LocalUserCreationForm):
for f in ro:
self.fields[f].widget.attrs['readonly'] = True
def save(self, commit=True, *args, **kwargs):
def save(self, commit=True, **kwargs):
user = super(InvitedLocalUserCreationForm, self).save(commit=False,
*args, **kwargs)
**kwargs)
user.set_invitations_level()
user.email_verified = True
if commit:
user.save(*args, **kwargs)
user.save(**kwargs)
return user
......@@ -299,14 +298,14 @@ class ThirdPartyUserCreationForm(forms.ModelForm, StoreUserMixin):
provider.add_to_user()
pending.delete()
def save(self, commit=True, *args, **kwargs):
def save(self, commit=True, **kwargs):
user = super(ThirdPartyUserCreationForm, self).save(commit=False,
*args, **kwargs)
**kwargs)
user.set_unusable_password()
user.renew_token()
user.date_signed_terms = datetime.now()
if commit:
user.save(*args, **kwargs)
user.save(**kwargs)
logger.info('Created user %s' % user.log_display)
return user
......@@ -327,13 +326,13 @@ class InvitedThirdPartyUserCreationForm(ThirdPartyUserCreationForm):
for f in ro:
self.fields[f].widget.attrs['readonly'] = True
def save(self, commit=True, *args, **kwargs):
user = super(InvitedThirdPartyUserCreationForm, self).save(
commit=False, *args, **kwargs)
def save(self, commit=True, **kwargs):
user = super(InvitedThirdPartyUserCreationForm, self).save(commit=False,
**kwargs)
user.set_invitation_level()
user.email_verified = True
if commit:
user.save(*args, **kwargs)
user.save(**kwargs)
return user
......@@ -459,8 +458,8 @@ class ProfileForm(forms.ModelForm):
def clean_email(self):
return self.instance.email
def save(self, commit=True, *args, **kwargs):
user = super(ProfileForm, self).save(commit=False, *args, **kwargs)
def save(self, commit=True, **kwargs):
user = super(ProfileForm, self).save(commit=False, **kwargs)
user.is_verified = True
if self.cleaned_data.get('renew'):
user.renew_token(
......@@ -468,7 +467,7 @@ class ProfileForm(forms.ModelForm):
current_key=self.session_key
)
if commit:
user.save(*args, **kwargs)
user.save(**kwargs)
return user
......@@ -526,7 +525,7 @@ class ExtendedPasswordResetForm(PasswordResetForm):
def save(self, domain_override=None,
email_template_name='registration/password_reset_email.html',
use_https=False, token_generator=default_token_generator,
request=None, *args, **kwargs):
request=None, **kwargs):
"""
Generates a one-use only link for resetting password
and sends to the user.
......@@ -565,8 +564,8 @@ class EmailChangeForm(forms.ModelForm):
def save(self, request,
email_template_name='registration/email_change_email.txt',
commit=True, *args, **kwargs):
ec = super(EmailChangeForm, self).save(commit=False, *args, **kwargs)
commit=True, **kwargs):
ec = super(EmailChangeForm, self).save(commit=False, **kwargs)
ec.user = request.user
# delete pending email changes
request.user.emailchanges.all().delete()
......@@ -575,7 +574,7 @@ class EmailChangeForm(forms.ModelForm):
str(random()) + smart_str(ec.new_email_address))
ec.activation_key = activation_key.hexdigest()
if commit:
ec.save(*args, **kwargs)
ec.save(**kwargs)
send_change_email(ec, request, email_template_name=email_template_name)
......@@ -594,11 +593,11 @@ class SignApprovalTermsForm(forms.ModelForm):
raise forms.ValidationError(_(astakos_messages.SIGN_TERMS))
return has_signed_terms
def save(self, commit=True, *args, **kwargs):
user = super(SignApprovalTermsForm, self).save(commit, *args, **kwargs)
def save(self, commit=True, **kwargs):
user = super(SignApprovalTermsForm, self).save(commit=commit, **kwargs)
user.date_signed_terms = datetime.now()
if commit:
user.save(*args, **kwargs)
user.save(**kwargs)
return user
......@@ -637,7 +636,7 @@ class ExtendedPasswordChangeForm(PasswordChangeForm):
self.session_key = kwargs.pop('session_key', None)
super(ExtendedPasswordChangeForm, self).__init__(user, *args, **kwargs)
def save(self, commit=True, *args, **kwargs):
def save(self, commit=True, **kwargs):
try:
if settings.NEWPASSWD_INVALIDATE_TOKEN or \
self.cleaned_data.get('renew'):
......@@ -647,7 +646,7 @@ class ExtendedPasswordChangeForm(PasswordChangeForm):
# if user model does has not such methods
pass
return super(ExtendedPasswordChangeForm, self).save(commit=commit,
*args, **kwargs)
**kwargs)
class ExtendedSetPasswordForm(SetPasswordForm):
"""
......@@ -665,7 +664,7 @@ class ExtendedSetPasswordForm(SetPasswordForm):
super(ExtendedSetPasswordForm, self).__init__(user, *args, **kwargs)
@transaction.commit_on_success()
def save(self, commit=True, *args, **kwargs):
def save(self, commit=True, **kwargs):
try:
self.user = AstakosUser.objects.get(id=self.user.id)
if settings.NEWPASSWD_INVALIDATE_TOKEN or \
......@@ -679,7 +678,7 @@ class ExtendedSetPasswordForm(SetPasswordForm):
except BaseException, e:
logger.exception(e)
return super(ExtendedSetPasswordForm, self).save(commit=commit,
*args, **kwargs)
**kwargs)
......@@ -905,7 +904,7 @@ class ProjectApplicationForm(forms.ModelForm):
def cleaned_resource_policies(self):
return [(d['name'], d['uplimit']) for d in self.resource_policies]
def save(self, commit=True, *args, **kwargs):
def save(self, commit=True, **kwargs):
data = dict(self.cleaned_data)
data['precursor_id'] = self.instance.id
is_new = self.instance.id is None
......
......@@ -511,7 +511,7 @@ class AstakosUser(User):
self.uuid = uuid_val
return self.uuid
def save(self, update_timestamps=True, *args, **kwargs):
def save(self, update_timestamps=True, **kwargs):
if update_timestamps:
if not self.id:
self.date_joined = datetime.now()
......@@ -526,7 +526,7 @@ class AstakosUser(User):
if self.username != self.email.lower():
self.username = self.email.lower()
super(AstakosUser, self).save(*args, **kwargs)
super(AstakosUser, self).save(**kwargs)
def renew_verification_code(self):
self.verification_code = str(uuid.uuid4())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment