Esempio n. 1
0
File: views.py Progetto: kamni/zorna
def change_my_password(request):
    if not request.user.is_anonymous():
        from zorna.account.forms import AccountEditPasswordForm
        user = request.user
        if request.method == 'POST':
            form = AccountEditPasswordForm(data=request.POST)
            if form.is_valid():
                user.set_password(form.cleaned_data['password1'])
                user.save()
                return user_settings(request)
            else:
                form = AccountEditPasswordForm(data=request.POST)
        else:
            form = AccountEditPasswordForm()
        context = RequestContext(request)
        return render_to_response("account/change_my_password.html", {'form': form}, context_instance=context)
    else:
        return HttpResponseRedirect('/')
Esempio n. 2
0
File: views.py Progetto: kamni/zorna
def edit_user_password(request, user):
    baccess = SiteOptions.objects.is_access_valid(
        request.user, 'zorna_validate_registration')
    if request.user.is_superuser or baccess:
        from zorna.account.forms import AccountEditPasswordForm
        user = User.objects.get(pk=user)
        if request.method == 'POST':
            form = AccountEditPasswordForm(data=request.POST)
            if form.is_valid():
                user.set_password(form.cleaned_data['password1'])
                user.save()
                return HttpResponseRedirect(reverse('list_users'))
            else:
                form = AccountEditPasswordForm(data=request.POST)
        else:
            form = AccountEditPasswordForm()
        context = RequestContext(request)
        return render_to_response("account/edit_password_user.html", {'form': form, 'curuser': user}, context_instance=context)
    else:
        return HttpResponseRedirect('/')