예제 #1
0
 def test_email(self):
     #Test no repetir email
     form_data = self.form_data.copy()
     form_data['email'] = "*****@*****.**"
     form = UserCreateForm(
         data=form_data)
     self.assertEqual(form.is_valid(), False)
예제 #2
0
 def test_password(self):
     #Password no coinciden
     form_data = self.form_data.copy()
     form_data['password1'] = "u1234"
     form = UserCreateForm(
         data=form_data)
     self.assertEqual(form.is_valid(), False)
예제 #3
0
 def test_usuario(self):
     #Test usuario no repetir
     form_data = self.form_data.copy()
     form_data['username'] = "******"
     form = UserCreateForm(
         data=form_data)
     self.assertEqual(form.is_valid(), False)
예제 #4
0
 def test_ok(self):
     #Test con data OK
     form_data = self.form_data.copy()
     form_data['username'] = '******'
     form_data['email'] = '*****@*****.**'
     form = UserCreateForm(
         data=form_data)
     self.assertEqual(form.is_valid(), True)
예제 #5
0
def newuser(request):
	if request.method == 'POST':
		formulario = UserCreateForm(request.POST)
		if formulario.is_valid:
			message1 = "Usuario registrado correctamente"
			formulario.save()
			formulario = UserCreateForm();
			return render_to_response('usuarios/new_user.html',{'formulario':formulario,'message1':message1},context_instance = RequestContext(request))
	else:
		formulario = UserCreateForm();
		return render_to_response('usuarios/new_user.html',{'formulario':formulario},context_instance = RequestContext(request))
예제 #6
0
파일: views.py 프로젝트: Codectivo/Incubu
def registra(request):
    output = {}
    if request.method == 'POST':
        form_reg = UserCreateForm(data=request.POST)
        if form_reg.is_valid():
            username = request.POST.get('username')
            email = request.POST.get('email')
            password = request.POST.get('password1')
            userDB = User.objects.create_user(username, email, password)
            userDB.save()
            access = authenticate(username=username, password=password)
            login(request, access)
            return HttpResponseRedirect('/usuario/escritorio/')
        else:
            output['errors'] = 'Ha ocurrido un error favor de revisar el formulario'
    else:
        form_reg = UserCreateForm()
    output['usuario_registra'] = form_reg
    return render(request, "usuarios/registra.html", output)
예제 #7
0
파일: views.py 프로젝트: jmtmacias/ansa
def newuser(request):
    if request.method == 'POST':
        formulario = UserCreateForm(request.POST)
        if formulario.is_valid:
            message1 = "Usuario registrado correctamente"
            formulario.save()
            formulario = UserCreateForm()
            return render_to_response('usuarios/new_user.html', {
                'formulario': formulario,
                'message1': message1
            },
                                      context_instance=RequestContext(request))
    else:
        formulario = UserCreateForm()
        return render_to_response('usuarios/new_user.html',
                                  {'formulario': formulario},
                                  context_instance=RequestContext(request))
예제 #8
0
def usuario_nuevo(request):
    if request.method == 'POST':
        formulario = UserCreateForm()
        if formulario.is_valid:
            formulario.save()
            formulario = UserCreateForm()
            return HttpResponseRedirect('/definir/usuarios/lista/')
    else:
        formulario_user = UserCreateForm()
        formulario_perfil = PerfilForm()
        message = "Si estan pasando"
        return render_to_response('usuarios/perfil.html', {
            'formulario': formulario_perfil,
            'formulario1': formulario_user,
            'message': message
        },
                                  context_instance=RequestContext(request))