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


Python AdminPasswordChangeForm.is_valid方法代码示例

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


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

示例1: recover_pass

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:33,代码来源:views.py

示例2: test_password_whitespace_not_stripped

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
 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,代码行数:9,代码来源:test_forms.py

示例3: user_change_password

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:28,代码来源:views.py

示例4: user_recoverpass

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:31,代码来源:views.py

示例5: password_nuevo

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
def password_nuevo(request):
    algo=""
    if request.method == 'POST' :
        formulario2=newpass(request.POST)
        if formulario2.is_valid():
            contrasena=request.POST['actual_password']
            usuario=request.user
            acceso=authenticate(username=usuario,password=contrasena)
            if acceso is not None:
                formulario = AdminPasswordChangeForm(user=usuario, data=request.POST)
                if formulario.is_valid():
                    formulario.save()
                    logout(request)
                return HttpResponseRedirect("/db/menu/loginlink/")
                pass
            else:
                formulario = AdminPasswordChangeForm(user=request.user)
                formulario2 = newpass()
                algo="Las contrasena actual no es la misma"
                return render_to_response('repassword.html', {'formulario' :formulario, "formulario2": formulario2, "algo": algo}, context_instance=RequestContext(request))
            pass
    else:
        formulario = AdminPasswordChangeForm(user=request.user)
        formulario2 = newpass()
    return  render_to_response('repassword.html', {'formulario' :formulario, "formulario2": formulario2}, context_instance=RequestContext(request))
开发者ID:AngelaAlbino,项目名称:venta,代码行数:27,代码来源:views.py

示例6: reset_pass

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:11,代码来源:views.py

示例7: test_success

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
 def test_success(self, password_changed):
     user = User.objects.get(username="testclient")
     data = {"password1": "test123", "password2": "test123"}
     form = AdminPasswordChangeForm(user, data)
     self.assertTrue(form.is_valid())
     form.save(commit=False)
     self.assertEqual(password_changed.call_count, 0)
     form.save()
     self.assertEqual(password_changed.call_count, 1)
开发者ID:uranusjr,项目名称:django,代码行数:11,代码来源:test_forms.py

示例8: test_password_whitespace_not_stripped

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
 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,代码行数:12,代码来源:test_forms.py

示例9: modifica_password_utente

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:12,代码来源:views.py

示例10: password_change

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:13,代码来源:views.py

示例11: cambiar_password

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:13,代码来源:views.py

示例12: user_changepassword

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:13,代码来源:views.py

示例13: password_change

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:14,代码来源:views.py

示例14: update_user_password

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:14,代码来源:views.py

示例15: reset_pass

# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import is_valid [as 别名]
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,代码行数:15,代码来源:views.py


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