Merge: palestrante edita palestra.
authorwww-data <www-data@mail.holoscopio.com>
Thu, 13 Sep 2007 13:20:25 +0000 (10:20 -0300)
committerwww-data <www-data@mail.holoscopio.com>
Thu, 13 Sep 2007 13:20:25 +0000 (10:20 -0300)
eventos/models.py
forms.py
templates/editar_trabalho.html [new file with mode: 0644]
templates/meus_trabalhos.html
urls.py
views.py

index 3d51818..eda0771 100644 (file)
@@ -41,9 +41,9 @@ class Evento(models.Model):
 
     class Admin:
         fields = (
 
     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',
             ('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):
         )
 
     def __str__(self):
index 7890fc6..8dc99df 100644 (file)
--- a/forms.py
+++ b/forms.py
@@ -52,7 +52,6 @@ class SubmeterTrabalho(forms.Form):
                   'ex.: Computadores, softwares, etc. Máximo de 300 caracteres.')
     outros_palestrantes = forms.MultipleChoiceField(required=0)
 
                   'ex.: Computadores, softwares, etc. Máximo de 300 caracteres.')
     outros_palestrantes = forms.MultipleChoiceField(required=0)
 
-
 class CadastroPalestrante(forms.Form):
     nome_completo = forms.CharField(max_length=100)
     nome_usuario = forms.CharField(max_length=100)
 class CadastroPalestrante(forms.Form):
     nome_completo = forms.CharField(max_length=100)
     nome_usuario = forms.CharField(max_length=100)
diff --git a/templates/editar_trabalho.html b/templates/editar_trabalho.html
new file mode 100644 (file)
index 0000000..38a4595
--- /dev/null
@@ -0,0 +1,18 @@
+{% extends "base.html" %}
+{% block content %}
+
+<h2>Editar trabalho</h2>
+
+{% if formulario %}
+<form method="post" action="">
+<table>  {{ formulario.as_table }}</table>
+<input type="submit" value="Modificar trabalho"/>
+</form>
+
+  
+
+{% else %}
+  <h3>O trabalho selecionado n&atilde;o existe, verifique o link</h3>
+{% endif %}
+
+{% endblock %}
index 84af9da..14bc58e 100644 (file)
@@ -3,6 +3,13 @@
 
 <h2>Trabalhos Inscritos</h2>
 
 
 <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>
 {% 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'^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),
     (r'^meus_dados/', views.meus_dados),
     (r'^chamada_trabalhos/', views.chamada_trabalhos),
     (r'^avaliacao/', views.avaliacao),
index f077444..58e9a37 100644 (file)
--- a/views.py
+++ b/views.py
@@ -17,7 +17,7 @@ License along with this program; if not, write to the
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.
 """
 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
 from django.contrib.auth.decorators import login_required, user_passes_test
 from django.contrib.auth.models import Group, User
 from django.template import RequestContext, Context
 from django.contrib.auth.decorators import login_required, user_passes_test
 from django.contrib.auth.models import Group, User
@@ -29,6 +29,7 @@ from eventmanager.decorators import enable_login_form
 from eventmanager.forms import *
 from eventmanager.conteudo.models import Noticia, Menu, Secao
 from eventmanager.eventos.models import *
 from eventmanager.forms import *
 from eventmanager.conteudo.models import Noticia, Menu, Secao
 from eventmanager.eventos.models import *
+from django.newforms import form_for_instance
 
 def build_response(request, template, extra={}):
     """
 
 def build_response(request, template, extra={}):
     """
@@ -174,11 +175,34 @@ def meus_trabalhos(request):
         # não palestrante...
         c = {'palestrante': 0}
         return build_response(request, 'meus_trabalhos.html', c)
         # 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)
 
     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
 def meus_dados(request):
 
 @login_required
 def meus_dados(request):