conferindo senha
authorLincoln de Sousa <pythonwarrior@pidinti.localdomain>
Tue, 14 Aug 2007 19:54:07 +0000 (16:54 -0300)
committerLincoln de Sousa <pythonwarrior@pidinti.localdomain>
Tue, 14 Aug 2007 19:54:07 +0000 (16:54 -0300)
forms.py
views.py

index 92bf0e8..4a2d71c 100644 (file)
--- a/forms.py
+++ b/forms.py
@@ -59,6 +59,8 @@ class CadastroPalestrante(forms.Form):
     nome_completo = forms.CharField(max_length=100)
     nome_usuario = forms.CharField(max_length=100)
     senha = forms.CharField(max_length=100, widget=PasswordInput())
+    senha_2 = forms.CharField(max_length=100, widget=PasswordInput(),
+        label='Conferir Senha')
     email = forms.CharField(max_length=100)
 
     telefone = forms.CharField(required=False)
index 0842afc..677bbc0 100644 (file)
--- a/views.py
+++ b/views.py
@@ -23,6 +23,7 @@ from django.contrib.auth.decorators import login_required, user_passes_test
 from django.contrib.auth.models import Group, User
 from django.contrib.auth.forms import AuthenticationForm
 from django.contrib.auth import login
+from django.db import transaction
 
 from eventmanager.decorators import enable_login_form
 from eventmanager.forms import *
@@ -58,6 +59,7 @@ def index(request):
     return build_response(request, 'index.html')
 
 
+@transaction.commit_manually
 @enable_login_form
 def cadastro_palestrante(request):
     c = {}
@@ -80,9 +82,15 @@ def cadastro_palestrante(request):
                 User.objects.get(username=cd['nome_usuario'])
                 badattr['nome_usuario'] = ['Este nome de usuário já existe!']
                 wrong = True
+                transaction.rollback()
             except User.DoesNotExist:
                 pass
 
+            if cd['senha'] != cd['senha_2']:
+                badattr['senha_2'] = ['A senha não confere']
+                wrong = True
+                transaction.rollback()
+
             if not wrong:
                 group = Group.objects.get_or_create(name='palestrantes')[0]
 
@@ -119,6 +127,7 @@ def cadastro_palestrante(request):
                 errors = manipulator.get_validation_errors(fakepost)
                 got_user = manipulator.get_user()
                 login(request, got_user)
+                transaction.commit()
     else:
         form = CadastroPalestrante()
     c.update({'form': form})