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 *
return build_response(request, 'index.html')
+@transaction.commit_manually
@enable_login_form
-def cadastro(request):
+def cadastro_palestrante(request):
c = {}
if request.POST:
# django's newforms lib requires a new instance of a form to be bounded
badattr = form.errors
wrong = False
- if not cd['telefone_comercial'] and \
- not cd['telefone_residencial'] and \
- not cd['telefone_celular']:
+ if not cd['telefone'] and not cd['celular']:
badattr['telefone_comercial'] = ['Algum número de telefone '
'precisa ser informado']
wrong = True
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]
p.nome = cd['nome_completo']
p.email = cd['email']
- p.telefone_comercial = cd['telefone_comercial']
- p.telefone_residencial = cd['telefone_residencial']
- p.telefone_celular = cd['telefone_celular']
+ p.telefone = cd['telefone']
+ p.celular = cd['celular']
p.rua = cd['rua']
p.numero = cd['numero']
p.bairro = cd['bairro']
errors = manipulator.get_validation_errors(fakepost)
got_user = manipulator.get_user()
login(request, got_user)
+ transaction.commit()
else:
form = CadastroPalestrante()
c.update({'form': form})
@login_required
@user_passes_test(lambda u:u.palestrante_set.count() == 1, login_url='/')
-def inscrever_palestra(request):
+def submeter_trabalho(request):
c = {}
if request.POST:
- form = InscreverPalestra(request.POST)
+ form = SubmeterTrabalho(request.POST)
if form.is_valid():
cd = form.cleaned_data
- p = Palestra()
+ p = Trabalho()
p.titulo = cd['titulo']
- p.tema = cd['tema']
- p.categoria = CategoriaPalestra.objects.get(pk=cd['categoria'])
+ p.tipo = TipoTrabalho.objects.get(pk=cd['tipo'])
+ p.categoria = CategoriaTrabalho.objects.get(pk=cd['categoria'])
p.descricao_curta = cd['descricao_curta']
p.descricao_longa = cd['descricao_longa']
+ p.recursos = cd['recursos']
p.evento = Evento.objects.get(pk=1) # let the hammer play arround!
p.save()
p.palestrante.add(up)
c.update({'ok': 1})
else:
- form = InscreverPalestra()
+ form = SubmeterTrabalho()
c.update({'form': form})
return build_response(request, 'inscrever_palestra.html', c)
c = {'palestrante': 0}
return build_response(request, 'meus_trabalhos.html', c)
- palestras = Palestra.objects.filter(palestrante=p)
- minicursos = MiniCurso.objects.filter()
- c = {'palestras': palestras, 'minicursos': minicursos, 'palestrante': 1}
+ t = Trabalho.objects.filter(palestrante=p)
+ c = {'trabalhos': t, 'palestrante': 1}
return build_response(request, 'meus_trabalhos.html', c)