+class LoginBase(forms.Form):
+ nome_usuario = forms.CharField(max_length=100)
+ senha = forms.CharField(max_length=100, widget=PasswordInput())
+ senha_2 = forms.CharField(max_length=100, widget=PasswordInput(),
+ label='Conferir Senha')
+
+ def clean_nome_usuario(self):
+ try:
+ User.objects.get(username=self.cleaned_data['nome_usuario'])
+ raise ValidationError('Já existe um usuário com esse nome')
+ except User.DoesNotExist:
+ return self.cleaned_data['nome_usuario']
+
+ def clean_senha_2(self):
+ if self.cleaned_data['senha'] != self.cleaned_data['senha_2']:
+ raise ValidationError('A confirmação não confere com a senha')
+ return self.cleaned_data['senha_2']
+
+class SubmeterTrabalho(forms.Form):
+ def __init__(self, request, *args, **kwargs):
+ super(SubmeterTrabalho, self).__init__(*args, **kwargs)
+
+ newchoices = MKCHOICES(TipoTrabalho)
+ self.fields['tipo'].choices = newchoices
+
+ 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')
+ tipo = forms.ChoiceField()
+ descricao_curta = forms.CharField(widget=Textarea(),
+ label='Descrição curta', max_length=250,
+ help_text='Esta descrição será utilizada para exibição no '
+ 'material de divulgação (máximo 250 caracteres).')
+ descricao_longa = forms.CharField(widget=Textarea(),
+ max_length=1500, label='Descrição longa',
+ help_text='Esta descrição será utilizada para avaliação do seu '
+ 'trabalho. Insira também referências '
+ '(máximo 1500 caracteres).')
+ recursos = forms.CharField(widget=Textarea(), max_length=300, required=0,
+ help_text='Liste os recursos que seu trabalho irá necessitar, '
+ 'ex.: Computadores, softwares, etc. Máximo de 300 caracteres.')
+ outros_palestrantes = forms.MultipleChoiceField(required=0)
+
+class CadastroPalestrante(LoginBase):
+ nome_completo = forms.CharField(max_length=100)