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')
@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():