adicionando patch do gabriel (brigaduxo =) e arrumando um probleminha no form de...
authorLincoln de Sousa <lincoln@archlinux-br.org>
Tue, 18 Sep 2007 21:47:57 +0000 (18:47 -0300)
committerLincoln de Sousa <lincoln@archlinux-br.org>
Tue, 18 Sep 2007 21:47:57 +0000 (18:47 -0300)
eventos/models.py
settings.py
templates/meus_trabalhos.html
urls.py
views.py

index 3d51818..eda0771 100644 (file)
@@ -41,9 +41,9 @@ class Evento(models.Model):
 
     class Admin:
         fields = (
-            (None, {'fields': ('nome', 'data_inicio', 'data_final')}),
+            ('Informações do evento', {'fields': ('nome', 'data_inicio', 'data_final')}),
             ('Informações da sede', {'fields': ('nome_local', 'nome_contato',
-                'cidade', 'uf', 'rua', 'numero', 'info_adicional')}),
+                'cidade', 'uf', 'rua', 'numero','telefone', 'info_adicional')}),
         )
 
     def __str__(self):
index 693a971..b52e14d 100644 (file)
@@ -24,7 +24,7 @@ DATABASE_PORT = ''             # Set to empty string for default. Not used with
 # although not all variations may be possible on all operating systems.
 # If running in a Windows environment this must be set to the same as your
 # system time zone.
-TIME_ZONE = 'America/Chicago'
+TIME_ZONE = 'America/Sao_paulo'
 
 # Language code for this installation. All choices can be found here:
 # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
index 84af9da..1aa3e83 100644 (file)
@@ -3,6 +3,13 @@
 
 <h2>Trabalhos Inscritos</h2>
 
+{# o if abaixo eh para o caso de algum trabalho ter sido editado e redirecionado #}
+{% if editado_sucesso %}
+  <br />
+  <h4>O trabalho "{{ editado_sucesso }}" for editado com sucesso!</h4>
+  <br />
+{% endif %}
+
 {% if trabalhos %}
 
     <ul>
diff --git a/urls.py b/urls.py
index b85168b..cf93987 100644 (file)
--- a/urls.py
+++ b/urls.py
@@ -32,6 +32,7 @@ urlpatterns = patterns('',
     (r'^submeter_trabalho/', views.submeter_trabalho),
     (r'^cadastro_palestrante/', views.cadastro_palestrante),
     (r'^meus_trabalhos/', views.meus_trabalhos),
+    (r'^trabalhos/(?P<codigo>\d+)', views.editar_trabalho),
     (r'^meus_dados/', views.meus_dados),
     (r'^chamada_trabalhos/', views.chamada_trabalhos),
     (r'^avaliacao/', views.avaliacao),
index e75b7e1..bf5db99 100644 (file)
--- a/views.py
+++ b/views.py
@@ -17,10 +17,11 @@ License along with this program; if not, write to the
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.
 """
-from django.shortcuts import render_to_response
+from django.shortcuts import render_to_response, get_object_or_404
 from django.template import RequestContext, Context, loader
 from django.contrib.auth.decorators import login_required, user_passes_test
 from django.contrib.auth.models import Group, User
+from django.newforms import form_for_instance
 from django.core.mail import EmailMessage
 from django.db import transaction
 from django.http import get_host
@@ -152,7 +153,7 @@ def inscricao(request):
         form = InscricaoEstudante(post2)
 
     # inscrição normal (sem ser estudante)
-    elif not 'estudante' in post or 'empresa' in post:
+    elif not 'estudante' in post and ('first_step' in post or 'empresa' in post):
         form = InscricaoNormal(post2)
 
     # primeiro passo...
@@ -205,6 +206,30 @@ def meus_trabalhos(request):
     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
 def meus_dados(request):