Ejemplo n.º 1
0
def profile_private_edit_password(request, template_password_form_name = 'auth/profile_private_edit_password_form.html'):
    password_form = ChangePasswordForm(request.user, request.POST or None)
    if request.POST.get('action') == 'password':
        if password_form.is_valid():
            password_form.save()
            if request.is_ajax():
                return json_template({'status': 'ok', 'text': _("Password successfully changed")},
                    template_password_form_name, {'password_form': password_form}) 
            request.user.message_set.create(message=ugettext(u"Password successfully changed."))
        else:
            if request.is_ajax():
                return json_template({'status': 'error', 'text': _('Password changing failed')}, 
                    template_password_form_name, {'password_form': password_form}) 
    if not request.is_ajax():
        return password_form
Ejemplo n.º 2
0
def profile_private_edit_email(request, template_email_form_name = 'auth/profile_private_edit_email_form.html'):
    email_form = ChangeEmailForm(request.user, request.POST or None)
    if request.POST.get('action') == 'email':
        if email_form.is_valid():
            email_form.save()
            email_form.data = {'email': ''}
            if request.is_ajax():
                return json_template({'status': 'ok', 'text': _("Email successfully changed.")},
                    template_email_form_name, {'email_form': email_form, 'request': request}) 
            request.user.message_set.create(message=ugettext(u"Email successfully changed."))
        else:
            if request.is_ajax():
                return json_template({'status': 'error', 'text': _('Email changing failed')}, 
                    template_email_form_name, {'email_form': email_form, 'request': request}) 
    if not request.is_ajax():
        return email_form