e5955b7fd3fc129284b796fce6cf7bd2a4a2d1d6
[cascardo/eventmanager.git] / eventos / models.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.db import models
21 from django.contrib.localflavor.br.br_states import STATE_CHOICES as _states
22 from django.contrib.auth.models import User
23
24 # bad hack!
25 STATE_CHOICES = [(x, unicode(y).encode('utf8')) for x, y in _states]
26 del _states
27
28 class Evento(models.Model):
29     nome = models.CharField(maxlength=100)
30     data_inicio = models.DateTimeField()
31     data_final = models.DateTimeField()
32
33     nome_local = models.CharField('Nome do local', maxlength=100)
34     nome_contato = models.CharField('Nome do contato', maxlength=100)
35     telefone = models.CharField(maxlength=100)
36     cidade = models.CharField(maxlength=100)
37     uf = models.CharField(maxlength=2, choices=STATE_CHOICES)
38     rua = models.CharField(maxlength=100)
39     numero = models.CharField('Número', maxlength=10)
40     info_adicional = models.TextField()
41
42     class Admin:
43         fields = (
44             ('Informações do evento', {'fields': ('nome', 'data_inicio', 'data_final')}),
45             ('Informações da sede', {'fields': ('nome_local', 'nome_contato',
46                 'cidade', 'uf', 'rua', 'numero','telefone', 'info_adicional')}),
47         )
48
49     def __str__(self):
50         return self.nome
51
52
53 class Palestrante(models.Model):
54     nome = models.CharField(maxlength=100)
55     email = models.CharField(maxlength=100)
56
57     telefone = models.CharField(maxlength=100, blank=True)
58     celular = models.CharField(maxlength=100, blank=True)
59
60     instituicao = models.CharField(maxlength=250, blank=True)
61
62     rua = models.CharField(maxlength=100)
63     numero = models.CharField(maxlength=10)
64     bairro = models.CharField(maxlength=100)
65     cidade = models.CharField(maxlength=100)
66     uf = models.CharField(maxlength=3)
67
68     minicurriculo = models.TextField('Mini currículo')
69     curriculo = models.TextField('Currículo')
70
71     usuario = models.ForeignKey(User)
72
73     class Admin:
74         fields = (
75             (None, {'fields': ('nome', 'email', 'instituicao',
76                 'minicurriculo', 'curriculo', 'usuario')}),
77             ('Telefones', {'fields': ('telefone', 'celular')}),
78             ('Endereço', {'fields': ('rua', 'numero',
79                 'bairro', 'cidade', 'uf')}),
80         )
81
82     def __str__(self):
83         return self.nome
84
85
86 class Participante(models.Model):
87     nome = models.CharField(maxlength=100)
88     email = models.CharField(maxlength=100)
89     rg = models.CharField(maxlength=100)
90     home_page = models.CharField(maxlength=100, blank=True)
91
92     telefone = models.CharField(maxlength=100, blank=True)
93     rua = models.CharField(maxlength=100)
94     numero = models.CharField(maxlength=10)
95     bairro = models.CharField(maxlength=100)
96     cidade = models.CharField(maxlength=100)
97     uf = models.CharField(maxlength=3)
98     cep = models.CharField(maxlength=8)
99     cpf_cnpj = models.CharField(maxlength=20, blank=True)
100
101     comercial = models.BooleanField(default=False)
102     usuario = models.ForeignKey(User)
103     refbanco = models.IntegerField(editable=False)
104
105     class Admin:
106         pass
107
108     def __str__(self):
109         return self.nome
110
111
112 class Caravana(models.Model):
113     coordenador = models.ForeignKey(Participante)
114     participantes = models.TextField()
115
116     class Admin:
117         pass
118
119     def __str__(self):
120         return str(self.coordenador)
121
122     def parsed_participantes(self):
123         real_data = []
124         for i in self.participantes.split('\n'):
125             if i.strip():
126                 nome, email = i.rsplit(' ', 1)
127                 real_data.append({'nome': nome, 'email': email})
128         return real_data
129
130 class CategoriaTrabalho(models.Model):
131     nome = models.CharField(maxlength=100)
132
133     class Admin:
134         pass
135
136     class Meta:
137         verbose_name = 'Categoria de trabalho'
138         verbose_name_plural = 'Categorias de trabalhos'
139
140     def __str__(self):
141         return self.nome
142
143
144 class TipoTrabalho(models.Model):
145     nome = models.CharField(maxlength=100)
146
147     class Admin:
148         pass
149
150     class Meta:
151         verbose_name = 'Tipo de trabalho'
152         verbose_name_plural = 'Tipos de trabalho'
153
154     def __str__(self):
155         return self.nome
156
157
158 class Trabalho(models.Model):
159     titulo = models.CharField(maxlength=100)
160     evento = models.ForeignKey(Evento)
161     tipo = models.ForeignKey(TipoTrabalho)
162     categoria = models.ForeignKey(CategoriaTrabalho)
163     palestrante = models.ManyToManyField(Palestrante)
164     descricao_curta = models.TextField()
165     descricao_longa = models.TextField()
166     recursos = models.TextField()
167     aprovado = models.BooleanField()
168     dia = models.DateField()
169
170     class Admin:
171         fields = (
172             (None, {'fields': ('titulo', 'evento', 'categoria', 'tipo',
173                 'palestrante', 'descricao_curta', 'descricao_longa',
174                 'recursos', 'aprovado', 'dia')}),
175         )
176
177     def __str__(self):
178         return self.titulo
179
180
181 class Avaliacao(models.Model):
182     avaliador = models.ManyToManyField(User)
183     comentario = models.TextField()
184     trabalho = models.ForeignKey(Trabalho)
185
186     class Admin:
187         pass
188
189     class Meta:
190         verbose_name = 'Avaliação'
191         verbose_name_plural = 'Avaliações'
192
193     def __str__(self):
194         return self.nome