From c692a61181fa1072017c7bef236ae7b2b576ed4b Mon Sep 17 00:00:00 2001 From: Lincoln de Sousa Date: Wed, 15 Aug 2007 20:15:30 -0300 Subject: [PATCH] =?utf8?q?remo=C3=A7=C3=A3o=20do=20usu=C3=A1rio=20autentic?= =?utf8?q?ado=20na=20lista=20de=20*outros=20palestrantes*?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- forms.py | 8 +++++--- views.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/forms.py b/forms.py index cf89425..90be3d6 100644 --- a/forms.py +++ b/forms.py @@ -22,16 +22,18 @@ from django.newforms.widgets import Textarea, PasswordInput from eventmanager.eventos.models import \ TipoTrabalho, CategoriaTrabalho, Palestrante, STATE_CHOICES -MKCHOICES = lambda K:[(x.id, str(x)) for x in K.objects.all()] +MKCHOICES = lambda K, xid=-1:[(x.id, str(x)) for x in K.objects.all() \ + if xid != x.id] class SubmeterTrabalho(forms.Form): - def __init__(self, *args, **kwargs): + def __init__(self, request, *args, **kwargs): super(SubmeterTrabalho, self).__init__(*args, **kwargs) newchoices = MKCHOICES(TipoTrabalho) self.fields['tipo'].choices = newchoices - newchoices = MKCHOICES(Palestrante) + palestrante = request.user.palestrante_set.get() + newchoices = MKCHOICES(Palestrante, xid=palestrante.id) self.fields['outros_palestrantes'].choices = newchoices titulo = forms.CharField(max_length=100, label='Título do trabalho') diff --git a/views.py b/views.py index 355e5fa..52bae56 100644 --- a/views.py +++ b/views.py @@ -139,7 +139,7 @@ def inscricao(request): @login_required @user_passes_test(lambda u:u.palestrante_set.count() == 1, login_url='/') def submeter_trabalho(request): - form = SubmeterTrabalho(request.POST or None) + form = SubmeterTrabalho(request, request.POST or None) ok = False if request.POST and form.is_valid(): -- 2.20.1