当前位置: 首页>>代码示例>>Python>>正文


Python forms.AdminPasswordChangeForm类代码示例

本文整理汇总了Python中django.contrib.auth.forms.AdminPasswordChangeForm的典型用法代码示例。如果您正苦于以下问题:Python AdminPasswordChangeForm类的具体用法?Python AdminPasswordChangeForm怎么用?Python AdminPasswordChangeForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AdminPasswordChangeForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: user_change_password

def user_change_password(request, id):
    if not request.user.has_perm('auth.change_user'):
        raise PermissionDenied
    user = get_object_or_404(User, pk=id)
    manipulator = AdminPasswordChangeForm(user)
    if request.method == 'POST':
        new_data = request.POST.copy()
        errors = manipulator.get_validation_errors(new_data)
        if not errors:
            new_user = manipulator.save(new_data)
            msg = _('Password changed successfully.')
            request.user.message_set.create(message=msg)
            return HttpResponseRedirect('..')
    else:
        errors = new_data = {}
    form = oldforms.FormWrapper(manipulator, new_data, errors)
    return render_to_response('admin/auth/user/change_password.html', {
        'title': _('Change password: %s') % escape(user.username),
        'form': form,
        'is_popup': '_popup' in request.REQUEST,
        'add': True,
        'change': False,
        'has_delete_permission': False,
        'has_change_permission': True,
        'has_absolute_url': False,
        'first_form_field_id': 'id_password1',
        'opts': User._meta,
        'original': user,
        'show_save': True,
    }, context_instance=template.RequestContext(request))
开发者ID:BobPyron,项目名称:SideBySideDiff,代码行数:30,代码来源:auth.py

示例2: recover_pass

def recover_pass(request):
    if Perfil.objects.filter(code_activation = request.GET['code']):
        perfil = Perfil.objects.get(code_activation = request.GET['code'])
        usuario = User.objects.get(id = perfil.usuario_id)
        categorias = Categorias.objects.all()
        envio = perfil.time + timedelta(hours=2)
        hoy = datetime.now()
        if envio.strftime("%Y-%m-%d %H:%M") >= hoy.strftime("%Y-%m-%d %H:%M"):
            if request.method == 'POST':
                formulario = AdminPasswordChangeForm(user=usuario, data=request.POST)
                if formulario.is_valid():
                    formulario.save()
                    perfil.code_activation += usuario.username
                    perfil.save()
                    sms = "Contraseña Cambiada Correctamente"
                    messages.success(request, sms)
                    return HttpResponseRedirect(reverse(loguet_in))
            else:
                formulario = AdminPasswordChangeForm(user=usuario)
            return render(request, 'users/change_pass.html', {
                'formulario':formulario,
                'categorias':categorias,
            })
        else:
            sms = "El Enlace ya expiro por favor solicite uno nuevo"
            messages.error(request, sms, 'danger')
            return HttpResponseRedirect(reverse(sent_code_reset_pass))
    else:
        sms = "Enlace no Valido"
        messages.error(request, sms, 'danger')
        return HttpResponseRedirect(reverse(sent_code_reset_pass))
开发者ID:RogerMendez,项目名称:ahiteveo,代码行数:31,代码来源:views.py

示例3: user_recoverpass

def user_recoverpass(request, user_id, code):
    if ActivationCode.objects.filter(user_id = user_id, state = True, code = code, description='Reset Pass'):
        activation = ActivationCode.objects.get(user_id = user_id, state = True, code = code, description='Reset Pass')
        user = User.objects.get(id = user_id)
        envio = activation.send_time + timedelta(hours=24)
        today = datetime.now()
        if envio.strftime("%Y-%m-%d %H:%M") >= today.strftime("%Y-%m-%d %H:%M"):
            if request.method == 'POST':
                form = AdminPasswordChangeForm(user=user, data=request.POST)
                if form.is_valid():
                    form.save()
                    activation.state = False
                    activation.save()
                    sms = "Contraseña Cambiada Correctamente"
                    messages.success(request, sms)
                    return HttpResponseRedirect(reverse(user_login))
            else:
                form = AdminPasswordChangeForm(user=user)
            return render(request, 'users/reset_pass.html', {
                'form':form,
            })
        else:
            sms = "El Enlace ya expiro por favor solicite uno nuevo"
            messages.error(request, sms, 'danger')
            return HttpResponseRedirect(reverse(user-user-user_sendcoderesetpass))
    else:
        sms = "Enlace no Valido"
        messages.error(request, sms, 'danger')
        return HttpResponseRedirect('/')
开发者ID:RogerMendez,项目名称:prospection,代码行数:29,代码来源:views.py

示例4: test_password_whitespace_not_stripped

 def test_password_whitespace_not_stripped(self):
     user = User.objects.get(username="testclient")
     data = {"password1": " pass ", "password2": " pass "}
     form = AdminPasswordChangeForm(user, data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.cleaned_data["password1"], data["password1"])
     self.assertEqual(form.cleaned_data["password2"], data["password2"])
开发者ID:uranusjr,项目名称:django,代码行数:7,代码来源:test_forms.py

示例5: user_change_password

def user_change_password(request, id):
    if not request.user.has_perm('auth.change_user'):
        raise PermissionDenied
    user = get_object_or_404(User, pk=id)
    if request.method == 'POST':
        form = AdminPasswordChangeForm(user, request.POST)
        if form.is_valid():
            new_user = form.save()
            msg = _('Password changed successfully.')
            request.user.message_set.create(message=msg)
            return HttpResponseRedirect('..')
    else:
        form = AdminPasswordChangeForm(user)
    return render_to_response('admin/auth/user/change_password.html', {
        'title': _('Change password: %s') % escape(user.username),
        'form': form,
        'is_popup': '_popup' in request.REQUEST,
        'add': True,
        'change': False,
        'has_delete_permission': False,
        'has_change_permission': True,
        'has_absolute_url': False,
        'opts': User._meta,
        'original': user,
        'show_save': True,
    }, context_instance=RequestContext(request))
开发者ID:rawwell,项目名称:django,代码行数:26,代码来源:views.py

示例6: reset_pass

def reset_pass(request):
    if request.method == 'POST' :
        formulario = AdminPasswordChangeForm(user=request.user, data=request.POST)
        if formulario.is_valid():
            formulario.save()
            return HttpResponseRedirect('/user/login')
    else:
        formulario = AdminPasswordChangeForm(user=request.user)
    return  render_to_response('user/reset_pass.html', {'formulario' :formulario}, context_instance=RequestContext(request))
开发者ID:Xxsetrock,项目名称:TestGitHab,代码行数:9,代码来源:views.py

示例7: test_password_whitespace_not_stripped

 def test_password_whitespace_not_stripped(self):
     user = User.objects.get(username='testclient')
     data = {
         'password1': ' pass ',
         'password2': ' pass ',
     }
     form = AdminPasswordChangeForm(user, data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.cleaned_data['password1'], data['password1'])
     self.assertEqual(form.cleaned_data['password2'], data['password2'])
开发者ID:DAWZayas-Projects,项目名称:TEJEDOR-RETUERTO-ALEJANDRO,代码行数:10,代码来源:test_forms.py

示例8: modifica_password_utente

def modifica_password_utente(request,utente_id):
	user = User.objects.get(id=utente_id)
	if request.method == 'POST': # If the form has been submitted...
		form = AdminPasswordChangeForm(user=user, data=request.POST)
		if form.is_valid():
			form.save()
			return HttpResponseRedirect('/utenti/') # Redirect after POST
	else:
		form = AdminPasswordChangeForm(user=user)
	return render(request,'form_password_utente.html',{'request':request, 'form': form, 'user': user,})
开发者ID:emergenzeHack,项目名称:get2,代码行数:10,代码来源:views.py

示例9: user_changepassword

def user_changepassword(request):
    if request.method == 'POST' :
        form = AdminPasswordChangeForm(user=request.user, data=request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse(user_notification))
    else:
        form= AdminPasswordChangeForm(user=request.user)
    return  render(request, 'users/change_pass.html', {
        'form' :form,
    })
开发者ID:RogerMendez,项目名称:prospection,代码行数:11,代码来源:views.py

示例10: cambiar_password

def cambiar_password(request):
    if request.method == 'POST' :
        formulario = AdminPasswordChangeForm(user=request.user, data=request.POST)
        if formulario.is_valid():
            formulario.save()
            return HttpResponseRedirect(reverse(iniciar_sesion))
    else:
        formulario = AdminPasswordChangeForm(user=request.user)
    return  render(request, 'users/reset_pass.html', {
        'formulario' :formulario,
        })
开发者ID:fr2percy,项目名称:project,代码行数:11,代码来源:views.py

示例11: password_change

def password_change(req):
    user_to_edit = User.objects.get(id=req.user.id)
    if req.method == 'POST': 
        password_form = AdminPasswordChangeForm(user_to_edit, req.POST)
        if password_form.is_valid():
            password_form.save()
            return HttpResponseRedirect('/')
    else:
        password_form = AdminPasswordChangeForm(user_to_edit)
    template_name="password_change.html"
    return render_to_response(req, template_name, {"form" : password_form})
开发者ID:commtrack,项目名称:AquaTests,代码行数:11,代码来源:views.py

示例12: update_user_password

def update_user_password(request, user_id):
    user = User.objects.get(id=user_id)
    if request.method == 'GET':
        form = AdminPasswordChangeForm(user, None)
        return render_to_response('update_password.html', {'form':form, 'editing':True, 'site_user':user}, context_instance=RequestContext(request))

    if request.method == 'POST':
        form = AdminPasswordChangeForm(user,request.POST)
        if form.is_valid():
            form.save()
            return redirect(reverse_lazy('users:edit_user',kwargs={'user_id':str(user.id)}))
        return render_to_response('update_password.html', {'form':form, 'editing':True, 'site_user':user}, context_instance=RequestContext(request))
开发者ID:HanabiDev,项目名称:FORAVI,代码行数:12,代码来源:views.py

示例13: password_change

def password_change(req, id):
    user_to_edit = User.objects.get(id=id)
    print req.user
    if req.method == "POST":
        password_form = AdminPasswordChangeForm(user_to_edit, req.POST)
        if password_form.is_valid():
            password_form.save()
            return HttpResponseRedirect("/iavi/users/%s/edit" % user_to_edit.id)
    else:
        password_form = AdminPasswordChangeForm(user_to_edit)
    template_name = "iavi/password_change.html"
    return render_to_response(req, template_name, {"current_user": user_to_edit, "form": password_form})
开发者ID:unicefnigeria,项目名称:rapidsms,代码行数:12,代码来源:views.py

示例14: reset_pass

def reset_pass(request):
    perfil = Perfil.objects.get(usuario = request.user)
    if request.method == 'POST' :
        formulario = AdminPasswordChangeForm(user=request.user, data=request.POST)
        if formulario.is_valid():
            formulario.save()
            return HttpResponseRedirect(reverse(loguet_in))
    else:
        formulario = AdminPasswordChangeForm(user=request.user)
    return  render(request, 'users/reset_pass.html', {
        'formulario' :formulario,
        'perfil':perfil,
    })
开发者ID:RogerMendez,项目名称:ahiteveo,代码行数:13,代码来源:views.py

示例15: user_edit_password

def user_edit_password(request, user):
    if settings.EXTERNAL_AUTH:
        raise Http404()
    user = get_object_or_404(User, id=user)
    form = AdminPasswordChangeForm(user, request.POST or None)
    if request.method == 'POST' and form.is_valid():
        form.save()
        messages.success(request, 'User password modified successfully.')
        return redirect('show-user', user.id)
    return render(request, 'accounts/user_edit.html', {
        'user': user,
        'form': form,
    })
开发者ID:VinDuv,项目名称:ponytracker,代码行数:13,代码来源:views.py


注:本文中的django.contrib.auth.forms.AdminPasswordChangeForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。