本文整理汇总了Python中django.contrib.auth.forms.AdminPasswordChangeForm.save方法的典型用法代码示例。如果您正苦于以下问题:Python AdminPasswordChangeForm.save方法的具体用法?Python AdminPasswordChangeForm.save怎么用?Python AdminPasswordChangeForm.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.auth.forms.AdminPasswordChangeForm
的用法示例。
在下文中一共展示了AdminPasswordChangeForm.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: password_nuevo
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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))
示例2: user_recoverpass
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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('/')
示例3: recover_pass
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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))
示例4: test_success
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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)
示例5: reset_pass
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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))
示例6: modifica_password_utente
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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,})
示例7: user_changepassword
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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,
})
示例8: cambiar_password
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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,
})
示例9: password_change
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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})
示例10: update_user_password
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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))
示例11: password_change
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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})
示例12: change_password
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [as 别名]
def change_password(request):
if request.method == 'POST':
formulario = AdminPasswordChangeForm(user=request.user, data=request.POST)
if formulario.is_valid():
formulario.save()
sms = "Contraseña Modificada Correctamente"
messages.success(request, sms)
return HttpResponseRedirect(reverse(info_usuario))
else:
formulario = AdminPasswordChangeForm(user=request.user)
return render(request, 'usuarios/change_password.html', {
'formulario':formulario,
})
示例13: reset_pass
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [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,
})
示例14: user_edit_password
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [as 别名]
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,
})
示例15: definir_senha
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import save [as 别名]
def definir_senha(request, pk=None):
user_model = get_user_model()
user_obj = get_object_or_404(user_model, pk=pk)
if request.method == "POST":
form = AdminPasswordChangeForm(user=user_obj, data=request.POST)
if form.is_valid():
form.save()
update_session_auth_hash(request, form.user)
return HttpResponseRedirect(
reverse('agentes:agente:detalhes', args=[pk]))
else:
form = AdminPasswordChangeForm(user=request.user)
context = {'agente': user_obj, 'form': form, 'title': 'Redefinir senha'}
return render(request, 'registration/password_change_form.html', context)