X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=forms.py;h=90be3d663736999e5eb2500f0bfa1111b3cddd2f;hb=c692a61181fa1072017c7bef236ae7b2b576ed4b;hp=cf8942543108f94751d1508164eec267e7216d03;hpb=fee73a57bac5e6900e227ca03143313e92f7e933;p=cascardo%2Feventmanager.git 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')