Exemplo n.º 1
0
    def test_passwords(self):
        """Test password"""
        form_data = self.form_data.copy()
        #Password actual erroneo
        form_data['password_actual'] = 'err_password'
        form = UserEditForm(
            data=form_data,
            instance=self._user[0])
        self.assertEqual(form.is_valid(), False)

        # Password nuevos no coinciden
        form_data['password'] = '******'
        form = UserEditForm(
            data=form_data,
            instance=self._user[0])
        self.assertEqual(form.is_valid(), False)
Exemplo n.º 2
0
 def test_ok(self):
     """Testear con datos ok"""
     form_data = self.form_data.copy()
     form = UserEditForm(
         data=form_data,
         instance=self._user[1])
     print form.errors
     self.assertEqual(form.is_valid(), True)
Exemplo n.º 3
0
 def test_email(self):
     """Test no repetir email"""
     form_data = self.form_data.copy()
     form_data['email'] = '*****@*****.**'
     form = UserEditForm(
         data=form_data,
         instance=self._user[0])
     self.assertEqual(form.is_valid(), False)
Exemplo n.º 4
0
 def test_user(self):
     """Test no repetir user"""
     form_data = self.form_data.copy()
     form_data['username'] = '******'
     form = UserEditForm(
         data=form_data,
         instance=self._user[0])
     self.assertEqual(form.is_valid(), False)
Exemplo n.º 5
0
def configuracion(request):
    output = {}
    output['estatus'] = False
    if request.method == "POST":
        user_edit = UserEditForm(request.POST, instance=request.user)
        if user_edit.is_valid():
            password_actual = request.POST.get('password_actual')
            password = request.POST.get('password')
            repassword = request.POST.get('repassword')
            user_edit.save()
            if password_actual and password and repassword:
                request.user.set_password(password)
                request.user.save()
            output['estatus'] = True
    else:
        user_edit = UserEditForm(instance=request.user)
    output['user_edit_form'] = user_edit
    return render(request, "usuarios/configuracion.html", output)