Merge git://hammerboy.no-ip.org/eventmanager
[cascardo/eventmanager.git] / views.py
index 010afaf..4208dfa 100644 (file)
--- a/views.py
+++ b/views.py
@@ -146,7 +146,6 @@ def inscricao_individual(request):
     ok = False
     if request.POST and form.is_valid():
         cd = form.cleaned_data
-
         group = Group.objects.get_or_create(name='participantes')[0]
 
         user = User(username=cd['nome_usuario'], email=cd['email'])
@@ -168,6 +167,7 @@ def inscricao_individual(request):
         p.refbanco = 0
         p.telefone = cd['telefone']
         p.home_page = cd['home_page']
+        p.comercial = cd['inscricao_comercial']
         p.save()
 
         u = authenticate(username=cd['nome_usuario'], password=cd['senha'])
@@ -208,6 +208,7 @@ def inscricao_caravana(request):
         p.refbanco = 0
         p.telefone = cd['telefone']
         p.home_page = cd['home_page']
+        p.comercial = False # yeah, always false!
         p.save()
 
         c = Caravana()
@@ -238,7 +239,7 @@ def inscricao_boleto(request):
     initial = {}
 
     if p.refbanco == 0:
-        # o número refran deve ser gerado a cada novo boleto e deve ser único,
+        # o número refTran deve ser gerado a cada novo boleto e deve ser único,
         # mesmo para os testes
         refs = [x.refbanco for x in Participante.objects.all()]
         new_ref = len(refs)
@@ -253,8 +254,11 @@ def inscricao_boleto(request):
 
     initial['refTran'] = '1458197%s' % str(new_ref).zfill(10)
     if today < first_date:
-        initial['valor'] = '3500'
         initial['dtVenc'] = '12102007'
+        if not p.comercial:
+            initial['valor'] = '3500'
+        else:
+            initial['valor'] = '8000'
 
         # caso seja uma caravana...
         if ca and len(ca.parsed_participantes()) >= 10:
@@ -315,11 +319,34 @@ def meus_trabalhos(request):
         # não palestrante...
         c = {'palestrante': 0}
         return build_response(request, 'meus_trabalhos.html', c)
-
     t = Trabalho.objects.filter(palestrante=p)
     c = {'trabalhos': t, 'palestrante': 1}
     return build_response(request, 'meus_trabalhos.html', c)
 
+@login_required
+@user_passes_test(lambda u:u.palestrante_set.count() == 1, login_url='/')
+def editar_trabalho(request,codigo):
+    try:
+        p = Palestrante.objects.get(usuario=request.user)
+    except Palestrante.DoesNotExist:
+        # não palestrante...
+        c = {'palestrante': 0}
+        return build_response(request, 'meus_trabalhos.html', c)
+    trabalho = get_object_or_404(Trabalho, id=codigo,palestrante=p)
+    Formulario = form_for_instance(trabalho)
+    if request.method == 'POST':
+        form = Formulario(request.POST)
+        if form.is_valid():
+            form.save()
+            t = Trabalho.objects.filter(palestrante=p)
+            c = {'trabalhos': t, 'palestrante': 1}
+            c['editado_sucesso']=trabalho.titulo
+            return build_response(request, 'meus_trabalhos.html', c)
+    else:
+        form = Formulario()
+    
+    c = {'formulario':form}
+    return build_response(request, 'editar_trabalho.html', c)
 
 @login_required
 @user_passes_test(lambda u:u.palestrante_set.count() == 1, login_url='/')