Commit 7623667c authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Success messages on profile form submit

display messages based on action request after uses submitted the
profile form successfully
parent 50b572bd
......@@ -941,8 +941,11 @@ class ExtendedProfileForm(ProfileForm):
change_password = forms.BooleanField(initial=False, required=False)
change_email = forms.BooleanField(initial=False, required=False)
email_changed = False
password_changed = False
def __init__(self, *args, **kwargs):
self.fields_list = [
'email',
'new_email_address',
......@@ -1023,7 +1026,9 @@ class ExtendedProfileForm(ProfileForm):
def save(self, request, *args, **kwargs):
if 'email' in self.save_extra_forms:
self.email_change_form.save(request, *args, **kwargs)
self.email_changed = True
if 'password' in self.save_extra_forms:
self.password_change_form.save(*args, **kwargs)
self.password_changed = True
return super(ExtendedProfileForm, self).save(*args, **kwargs)
......@@ -48,6 +48,7 @@ ACCOUNT_ACTIVATED = 'Congratulations. Your account has'
' automatically signed in.'
PASSWORD_RESET_DONE = 'An email with details on how to change your password has been sent. Please check your Inbox.'
PASSWORD_RESET_CONFIRM_DONE = 'Your password has changed successfully. You can now login using your new password.'
PASSWORD_CHANGED = 'Your new password is set.'
ACCOUNT_RESEND_ACTIVATION_PROMPT = 'Resend activation email'
ACCOUNT_USER_ACTIVATION_PENDING = 'You have not followed the activation link'
......
......@@ -165,6 +165,8 @@ def password_change(request, template_name='registration/password_change_form.ht
form = password_change_form(**form_kwargs)
if form.is_valid():
form.save()
messages.success(request,
astakos_messages.PASSWORD_RESET_CONFIRM_DONE)
return HttpResponseRedirect(post_change_redirect)
else:
form = password_change_form(user=request.user)
......
......@@ -397,6 +397,14 @@ def edit_profile(request, template_name='im/profile.html', extra_context=None):
)
msg = _(astakos_messages.PROFILE_UPDATED)
messages.success(request, msg)
if form.email_changed:
msg = _(astakos_messages.EMAIL_CHANGE_REGISTERED)
messages.success(request, msg)
if form.password_changed:
msg = _(astakos_messages.PASSWORD_CHANGED)
messages.success(request, msg)
if next:
return redirect(next)
else:
......
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