Added Improve Class in eventos/models.py
[cascardo/ema.git] / eventos / models.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2008 Lincoln de Sousa <lincoln@minaslivre.org>
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public
15 # License along with this program; if not, write to the
16 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
18 from django.db import models
19 from django.contrib.localflavor.br.br_states import STATE_CHOICES
20 from django.contrib.auth.models import User
21 from django.contrib.sites.models import Site
22
23 class Evento(models.Model):
24     nome = models.CharField(max_length=100)
25     data_inicio = models.DateField(u'Data de início')
26     data_final = models.DateField()
27
28     local = models.CharField(max_length=100)
29     nome_contato = models.CharField(u'Nome do contato', max_length=100)
30     telefone = models.CharField(max_length=100)
31     endereco = models.TextField()
32     cidade = models.CharField(max_length=100)
33     estado = models.CharField(max_length=2, choices=STATE_CHOICES)
34     info_adicional = models.TextField(blank=True)
35
36     site = models.ForeignKey(Site)
37
38     def __str__(self):
39         return self.nome
40
41 class Palestrante(models.Model):
42     nome = models.CharField(max_length=100)
43     email = models.CharField(max_length=100)
44
45     telefone = models.CharField(max_length=100, blank=True)
46     celular = models.CharField(max_length=100, blank=True)
47
48     instituicao = models.CharField(u'Instituição', max_length=250, blank=True)
49
50     endereco = models.TextField()
51     cep = models.CharField(max_length=8)
52     cidade = models.CharField(max_length=100)
53     estado = models.CharField(max_length=2, choices=STATE_CHOICES)
54
55     minicurriculo = models.TextField(u'Mini currículo')
56     curriculo = models.TextField(u'Currículo')
57
58     usuario = models.ForeignKey(User, help_text=u'Este campo associa o '
59                                 'palestrante a uma conta no sistema para '
60                                 'que ele possa enviar trabalhos e alterar '
61                                 'dados pessoais.')
62     class Meta:
63         ordering = ['nome']
64
65     def __str__(self):
66         return self.nome
67
68 class TipoTrabalho(models.Model):
69     nome = models.CharField(max_length=100)
70     evento = models.ForeignKey(Evento)
71
72     class Meta:
73         verbose_name = u'Tipo de trabalho'
74         verbose_name_plural = u'Tipos de trabalho'
75
76     def __str__(self):
77         return self.nome
78
79 class Trilha(models.Model):
80     nome = models.CharField(max_length=100)
81     evento = models.ForeignKey(Evento)
82
83     def __str__(self):
84         return self.nome
85
86 class DuracaoTrabalho(models.Model):
87     duracao = models.CharField(u'Duração', max_length=100)
88     tipo = models.ForeignKey(TipoTrabalho)
89
90     class Meta:
91         verbose_name = u'Duração do Trabalho'
92         verbose_name_plural = u'Durações do Trabalho'
93
94     def __str__(self):
95         return self.duracao
96
97 class Trabalho(models.Model):
98     titulo = models.CharField(max_length=100)
99     evento = models.ForeignKey(Evento)
100     tipo = models.ForeignKey(TipoTrabalho)
101     trilha = models.ForeignKey(Trilha)
102     palestrante = models.ForeignKey(Palestrante)
103     descricao_curta = models.TextField(u'Descrição curta')
104     descricao_longa = models.TextField(u'Descrição longa')
105     recursos = models.TextField(blank=True)
106     duracao = models.ForeignKey(DuracaoTrabalho)
107     pub_date = models.DateTimeField(u'Data de criação', auto_now_add=True)
108     outros_palestrantes = \
109         models.ManyToManyField(Palestrante,
110                                related_name='outros_palestrantes',
111                                blank=True,
112                                null=True)
113
114     def __str__(self):
115         return self.titulo
116
117 class Improve(models.Model):
118     trabalho = models.ForeignKey(Trabalho)
119     usuario = models.ForeignKey(User, help_text=u'Este campo associa o '
120                             'palestrante a uma conta no sistema para '
121                             'que ele possa enviar trabalhos e alterar '
122                             'dados pessoais.')
123     comentario = models.TextField(u'Comentário')
124     pub_date = models.DateTimeField(u'Data do Comentário', auto_now_add=True)