remoção do usuário autenticado na lista de *outros palestrantes*
[cascardo/eventmanager.git] / forms.py
index cf89425..90be3d6 100644 (file)
--- 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')