ajeitando mensagens no form
[cascardo/eventmanager.git] / forms.py
1 # -*- coding: utf-8; -*-
2 """
3 Copyright (C) 2007 Lincoln de Sousa <lincoln@archlinux-br.org>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 """
20 from django import newforms as forms
21 from django.newforms.widgets import Textarea, PasswordInput
22 from eventmanager.eventos.models import \
23         TipoTrabalho, CategoriaTrabalho, Palestrante, STATE_CHOICES
24
25 MKCHOICES = lambda K, xid=-1:[(x.id, str(x)) for x in K.objects.all() \
26         if xid != x.id]
27
28 class SubmeterTrabalho(forms.Form):
29     def __init__(self, request, *args, **kwargs):
30         super(SubmeterTrabalho, self).__init__(*args, **kwargs)
31
32         newchoices = MKCHOICES(TipoTrabalho)
33         self.fields['tipo'].choices = newchoices
34
35         palestrante = request.user.palestrante_set.get()
36         newchoices = MKCHOICES(Palestrante, xid=palestrante.id)
37         self.fields['outros_palestrantes'].choices = newchoices
38
39     titulo = forms.CharField(max_length=100, label='Título do trabalho')
40     tipo = forms.ChoiceField()
41     descricao_curta = forms.CharField(widget=Textarea(),
42         label='Descrição curta', max_length=250,
43         help_text='Esta descrição será utilizada para exibição no '
44                   'material de divulgação (máximo 250 caracteres).')
45     descricao_longa = forms.CharField(widget=Textarea(),
46         max_length=1500, label='Descrição longa',
47         help_text='Esta descrição será utilizada para avaliação do seu '
48                   'trabalho. Insira também referências '
49                   '(máximo 1500 caracteres).')
50     recursos = forms.CharField(widget=Textarea(), max_length=300, required=0,
51         help_text='Liste os recursos que seu trabalho irá necessitar, '
52                   'ex.: Computadores, softwares, etc. Máximo de 300 caracteres.')
53     outros_palestrantes = forms.MultipleChoiceField(required=0)
54
55
56 class CadastroPalestrante(forms.Form):
57     nome_completo = forms.CharField(max_length=100)
58     nome_usuario = forms.CharField(max_length=100)
59     senha = forms.CharField(max_length=100, widget=PasswordInput())
60     senha_2 = forms.CharField(max_length=100, widget=PasswordInput(),
61         label='Conferir Senha')
62     email = forms.CharField(max_length=100)
63
64     telefone = forms.CharField(required=False)
65     celular = forms.CharField(required=False)
66
67     instituicao = forms.CharField(max_length=100, label='Instituição')
68     minicurriculo = forms.CharField(widget=Textarea(), max_length=250, label='Mini Currículo',
69        help_text='Este mini currículo será utilizado no material de divulgação '
70                  'e no sítio. Máximo de 250 caracteres.')
71     curriculo = forms.CharField(widget=Textarea(), max_length=6000, label='Currículo',
72        help_text='Este currículo será utilizado para avaliação do palestrante. '
73                  'Máximo de 6000 caracteres.')
74     rua = forms.CharField(max_length=100)
75     numero = forms.CharField(max_length=10, label='Número')
76     bairro = forms.CharField(max_length=100)
77     cidade = forms.CharField(max_length=100)
78     uf = forms.ChoiceField(choices=STATE_CHOICES)
79
80
81 class EditarPalestrante(forms.Form):
82     nome = forms.CharField(max_length=100, label='Nome completo')
83     email = forms.CharField(max_length=100)
84
85     telefone = forms.CharField(required=False)
86     celular = forms.CharField(required=False)
87
88     instituicao = forms.CharField(max_length=100, label='Instituição')
89     minicurriculo = forms.CharField(widget=Textarea(), max_length=250, label='Mini Currículo',
90        help_text='Este mini currículo será utilizado no material de divulgação'
91                  'e no site. Máximo de 250 caracteres.')
92     curriculo = forms.CharField(widget=Textarea(), max_length=6000, label='Currículo',
93        help_text='Este currículo será utilizado para avaliação do palestrante.'
94                  'Máximo de 6000 caracteres.')
95     rua = forms.CharField(max_length=100)
96     numero = forms.CharField(max_length=10, label='Número')
97     bairro = forms.CharField(max_length=100)
98     cidade = forms.CharField(max_length=100)
99     uf = forms.ChoiceField(choices=STATE_CHOICES)
100
101
102 class EditarSenha(forms.Form):
103     senha_atual = forms.CharField(max_length=100, widget=PasswordInput())
104     nova_senha = forms.CharField(max_length=100, widget=PasswordInput())
105     nova_senha_2 = forms.CharField(max_length=100, widget=PasswordInput(),
106         label='Conferir Senha')
107
108
109 class Inscricao(forms.Form):
110     nome_completo = forms.CharField(max_length=100)
111     cpf = forms.CharField(max_length=100)
112     email = forms.CharField(max_length=100)
113
114     rua = forms.CharField(max_length=100)
115     numero = forms.CharField(max_length=10, label='Número')
116     bairro = forms.CharField(max_length=100)
117     cidade = forms.CharField(max_length=100)
118     uf = forms.ChoiceField(choices=STATE_CHOICES)
119     pagina_pessoal = forms.CharField(max_length=100)
120
121     telefone = forms.CharField(max_length=100)
122     estudante = forms.BooleanField(required=False)
123
124     first_step = forms.CharField(max_length=1,
125             widget=forms.HiddenInput, initial='1')
126
127
128 class InscricaoEstudante(forms.Form):
129     post2 = forms.CharField(max_length=1,
130             widget=forms.HiddenInput, initial='1')
131     estudante = forms.CharField(max_length=1,
132             widget=forms.HiddenInput, initial='1')
133
134     instituicao = forms.CharField(max_length=100)
135     curso = forms.CharField(max_length=100)
136     periodo = forms.CharField(max_length=100)
137
138
139 class InscricaoNormal(forms.Form):
140     empresa = forms.CharField(max_length=100)
141     post2 = forms.CharField(max_length=1,
142             widget=forms.HiddenInput, initial='1')
143