Exemplo n.º 1
0
def password_change(request,
                    username,
                    template_name='userena/password_form.html',
                    pass_form=PasswordChangeForm,
                    success_url=None,
                    extra_context=None):

    user = get_object_or_404(User, username__iexact=username)

    profile = user.get_profile()

    user_initial = {'first_name': user.first_name, 'last_name': user.last_name}

    if not extra_context:
        extra_context = {}

    # Also pass the password and email forms
    extra_context.update({
        'password_form':
        PasswordChangeForm(user=request.user),
        'email_form':
        ChangeEmailForm(user=request.user),
        'profile_form':
        I4PEditProfileForm(instance=profile, initial=user_initial)
    })

    return userena_views.password_change(request=request,
                                         username=username,
                                         template_name=template_name,
                                         pass_form=pass_form,
                                         success_url=success_url,
                                         extra_context=extra_context)
Exemplo n.º 2
0
def password_change(request, username, template_name='userena/password_form.html',
                    pass_form=PasswordChangeForm, success_url=None, extra_context=None):

    user = get_object_or_404(User,
                             username__iexact=username)

    profile = user.get_profile()

    user_initial = {'first_name': user.first_name,
                    'last_name': user.last_name}

    if not extra_context:
        extra_context = {}

    # Also pass the password and email forms
    extra_context.update({'password_form': PasswordChangeForm(user=request.user),
                          'email_form': ChangeEmailForm(user=request.user),
                          'profile_form': I4PEditProfileForm(instance=profile, initial=user_initial)}
                         )

    return userena_views.password_change(request=request, 
                                         username=username, 
                                         template_name=template_name,
                                         pass_form=pass_form, 
                                         success_url=success_url, 
                                         extra_context=extra_context)
Exemplo n.º 3
0
def password_change_custom(request, username):
    """
    This was added because users created through django-social-auth don't
    have a usable password but we should allow them to set a new one.
    """
    if request.user.has_usable_password():
        pass_form = PasswordChangeForm
    else:
        pass_form = SetPasswordForm

    return password_change(request, username=username, pass_form=pass_form)
Exemplo n.º 4
0
def password_change_custom(request, username):
    """
    This was added because users created through django-social-auth don't
    have a usable password but we should allow them to set a new one.
    """
    if request.user.has_usable_password():
        pass_form = PasswordChangeForm
    else:
        pass_form = SetPasswordForm

    return password_change(request, username=username, pass_form=pass_form)
Exemplo n.º 5
0
def edit_password(request, username):
	extra_context = dict()
	return password_change(request, username=username, template_name='profile/password_form.html',
							success_url=reverse('userena_password_change_complete', args=[username]),
							extra_context=extra_context)