adicionando atributo usuário à entidade Palestrante
[cascardo/eventmanager.git] / eventos / models.py
1 # -*- coding: utf8; -*-
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             (None, {'fields': ('nome', 'data_inicio', 'data_final')}),
45             ('Informações da sede', {'fields': ('nome_local', 'nome_contato',
46                 'cidade', 'uf', 'rua', 'numero', 'info_adicional')}),
47         )
48
49     def __str__(self):
50         return self.nome
51
52
53 class AreaDeInteresse(models.Model):
54     nome = models.CharField(maxlength=100)
55
56     class Meta:
57         verbose_name = 'area de interesse'
58         verbose_name_plural = 'areas de interesse'
59
60     class Admin:
61         pass
62
63     def __str__(self):
64         return self.nome
65
66
67 class Palestrante(models.Model):
68     nome = models.CharField(maxlength=100)
69     email = models.CharField(maxlength=100)
70
71     telefone_residencial = models.CharField(maxlength=11, blank=True)
72     telefone_celular = models.CharField(maxlength=11, blank=True)
73     telefone_comercial = models.CharField(maxlength=11, blank=True)
74
75     rua = models.CharField(maxlength=100)
76     numero = models.CharField(maxlength=10)
77     bairro = models.CharField(maxlength=100)
78     cidade = models.CharField(maxlength=100)
79     uf = models.CharField(maxlength=3)
80
81     minicurriculo = models.TextField('Mini currículo')
82     area_interesse = models.ManyToManyField(AreaDeInteresse)
83
84     usuario = models.ForeignKey(User)
85
86     class Admin:
87         fields = (
88             (None, {'fields': ('nome', 'email', 'minicurriculo', 'usuario')}),
89             ('Telefones', {'fields': ('telefone_residencial',
90                 'telefone_celular', 'telefone_comercial')}),
91             ('Endereço', {'fields': ('rua', 'numero',
92                 'bairro', 'cidade', 'uf')}),
93             (None, {'fields': ('area_interesse',)}),
94         )
95
96     def __str__(self):
97         return self.nome
98
99
100 class Participante(models.Model):
101     nome = models.CharField(maxlength=100)
102
103     class Admin:
104         pass
105
106     def __str__(self):
107         return self.nome
108
109
110 class CategoriaPalestra(models.Model):
111     nome = models.CharField(maxlength=100)
112
113     class Admin:
114         pass
115
116     class Meta:
117         verbose_name = 'Categoria de palestra'
118         verbose_name_plural = 'Categorias de palestra'
119
120     def __str__(self):
121         return self.nome
122
123
124 class Palestra(models.Model):
125     titulo = models.CharField(maxlength=100)
126     tema = models.CharField(maxlength=100)
127     evento = models.ForeignKey(Evento)
128     categoria = models.ForeignKey(CategoriaPalestra)
129     palestrante = models.ManyToManyField(Palestrante)
130     descricao_curta = models.TextField()
131     descricao_longa = models.TextField()
132
133     class Admin:
134         fields = (
135             (None, {'fields': ('titulo', 'tema', 'evento', 'categoria',
136                 'palestrante', 'descricao_curta', 'descricao_longa')}),
137         )
138
139
140     def __str__(self):
141         return self.titulo
142
143
144 class MiniCurso(models.Model):
145     titulo = models.CharField(maxlength=100)
146
147     class Admin:
148         pass
149
150     def __str__(self):
151         return self.titulo