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):
(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),
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 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={}):
"""
# 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
def meus_dados(request):