colocando um layout tosco...
[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
22 class Evento(models.Model):
23     nome = models.CharField(max_length=100)
24     data_inicio = models.DateField(u'Data de início')
25     data_final = models.DateField()
26
27     local = models.CharField(max_length=100)
28     nome_contato = models.CharField(u'Nome do contato', max_length=100)
29     telefone = models.CharField(max_length=100)
30     endereco = models.TextField()
31     cidade = models.CharField(max_length=100)
32     estado = models.CharField(max_length=2, choices=STATE_CHOICES)
33     info_adicional = models.TextField(blank=True)
34
35     class Admin:
36         fields = (
37             (u'Informações do evento',
38              {'fields': ('nome', 'data_inicio', 'data_final')}),
39
40             (u'Informações da sede',
41              {'fields': ('local', 'nome_contato', 'endereco', 'cidade',
42                          'estado', 'telefone', 'info_adicional')}),
43         )
44
45         search_fields = list_display = 'nome', 'local'
46
47     def __str__(self):
48         return self.nome
49
50 class Palestrante(models.Model):
51     nome = models.CharField(max_length=100)
52     email = models.CharField(max_length=100)
53
54     telefone = models.CharField(max_length=100, blank=True)
55     celular = models.CharField(max_length=100, blank=True)
56
57     instituicao = models.CharField(u'Instituição', max_length=250, blank=True)
58
59     endereco = models.TextField()
60     cep = models.CharField(max_length=5)
61     cidade = models.CharField(max_length=100)
62     estado = models.CharField(max_length=2, choices=STATE_CHOICES)
63
64     minicurriculo = models.TextField(u'Mini currículo')
65     curriculo = models.TextField(u'Currículo')
66
67     usuario = models.ForeignKey(User, help_text=u'Este campo associa o '
68                                 'palestrante a uma conta no sistema para '
69                                 'que ele possa enviar trabalhos e alterar '
70                                 'dados pessoais.')
71
72     class Admin:
73         fields = (
74             (None, {'fields': ('nome', 'email', 'instituicao',
75                                'minicurriculo', 'curriculo')}),
76
77             (u'Telefones', {'fields': ('telefone', 'celular')}),
78
79             (u'Endereço', {'fields': ('endereco', 'cep', 'cidade', 'estado')}),
80
81             (u'Avançado', {'fields': ('usuario',),
82                            'classes': 'collapse'}),
83         )
84
85         search_fields = list_display = 'nome', 'instituicao', 'email', 'celular'
86
87     def __str__(self):
88         return self.nome
89
90 class TipoTrabalho(models.Model):
91     nome = models.CharField(max_length=100)
92
93     class Admin:
94         search_fields = 'nome',
95
96     class Meta:
97         verbose_name = u'Tipo de trabalho'
98         verbose_name_plural = u'Tipos de trabalho'
99
100     def __str__(self):
101         return self.nome
102
103 class Trabalho(models.Model):
104     titulo = models.CharField(max_length=100)
105     evento = models.ForeignKey(Evento)
106     tipo = models.ForeignKey(TipoTrabalho)
107     palestrante = models.ForeignKey(Palestrante)
108     descricao_curta = models.TextField(u'Descrição curta')
109     descricao_longa = models.TextField(u'Descrição longa')
110     recursos = models.TextField(blank=True)
111     outros_palestrantes = \
112         models.ManyToManyField(Palestrante,
113                                related_name='outros_palestrantes',
114                                blank=True,
115                                null=True)
116
117     class Admin:
118         list_filter = 'evento', 'tipo'
119         search_fields = list_display = 'titulo', 'evento', 'tipo'
120
121     def __str__(self):
122         return self.titulo