From 9a5b3597c49d9448b08afd6f7b1252d31a9f90b2 Mon Sep 17 00:00:00 2001 From: Lincoln de Sousa Date: Thu, 9 Aug 2007 15:40:45 -0300 Subject: [PATCH] arrumando o cadastro de palestrantes --- views.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/views.py b/views.py index 5e29b40..9d5d50a 100644 --- a/views.py +++ b/views.py @@ -47,17 +47,16 @@ def index(request): @enable_login_form def cadastro(request): + c = {} if request.POST: # django's newforms lib requires a new instance of a form to be bounded # with data, to be validated and used. form = CadastroPalestrante(request.POST) if form.is_valid(): cd = form.cleaned_data + badattr = form.errors wrong = False - # XXX: really ugly hack to use django validation machinary... - badattr = form._BaseForm__errors - if not cd['telefone_comercial'] and \ not cd['telefone_residencial'] and \ not cd['telefone_celular']: @@ -76,11 +75,13 @@ def cadastro(request): if not wrong: group = Group.objects.get_or_create(name='palestrantes')[0] + user = User(username=cd['nome_usuario'], email=cd['email']) + user.set_password(cd['senha']) + user.save() + user.groups.add(group) + p = Palestrante() - p.user = User(username=cd['nome_usuario'], email=cd['email']) - p.user.set_password(cd['senha']) - p.user.save() - p.user.groups.add(group) + p.usuario = user p.nome = cd['nome_completo'] p.email = cd['email'] @@ -110,7 +111,8 @@ def cadastro(request): login(request, got_user) else: form = CadastroPalestrante() - return build_response(request, 'cadastro.html', {'form': form}) + c.update({'form': form}) + return build_response(request, 'cadastro.html', c) @enable_login_form -- 2.20.1