adding images to the new layout
[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     class Admin:
39         fields = (
40             (u'Informações do evento',
41              {'fields': ('nome', 'data_inicio', 'data_final', 'site')}),
42
43             (u'Informações da sede',
44              {'fields': ('local', 'nome_contato', 'endereco', 'cidade',
45                          'estado', 'telefone', 'info_adicional')}),
46         )
47
48         search_fields = list_display = 'nome', 'local'
49
50     def __str__(self):
51         return self.nome
52
53 class Palestrante(models.Model):
54     nome = models.CharField(max_length=100)
55     email = models.CharField(max_length=100)
56
57     telefone = models.CharField(max_length=100, blank=True)
58     celular = models.CharField(max_length=100, blank=True)
59
60     instituicao = models.CharField(u'Instituição', max_length=250, blank=True)
61
62     endereco = models.TextField()
63     cep = models.CharField(max_length=8)
64     cidade = models.CharField(max_length=100)
65     estado = models.CharField(max_length=2, choices=STATE_CHOICES)
66
67     minicurriculo = models.TextField(u'Mini currículo')
68     curriculo = models.TextField(u'Currículo')
69
70     usuario = models.ForeignKey(User, help_text=u'Este campo associa o '
71                                 'palestrante a uma conta no sistema para '
72                                 'que ele possa enviar trabalhos e alterar '
73                                 'dados pessoais.')
74
75     class Admin:
76         fields = (
77             (None, {'fields': ('nome', 'email', 'instituicao',
78                                'minicurriculo', 'curriculo')}),
79
80             (u'Telefones', {'fields': ('telefone', 'celular')}),
81
82             (u'Endereço', {'fields': ('endereco', 'cep', 'cidade', 'estado')}),
83
84             (u'Avançado', {'fields': ('usuario',),
85                            'classes': 'collapse'}),
86         )
87
88         search_fields = list_display = 'nome', 'instituicao', 'email', 'celular'
89
90     def __str__(self):
91         return self.nome
92
93 class TipoTrabalho(models.Model):
94     nome = models.CharField(max_length=100)
95     evento = models.ForeignKey(Evento)
96
97     class Admin:
98         search_fields = 'nome',
99         list_filter = 'evento',
100
101     class Meta:
102         verbose_name = u'Tipo de trabalho'
103         verbose_name_plural = u'Tipos de trabalho'
104
105     def __str__(self):
106         return self.nome
107
108 class Trilha(models.Model):
109     nome = models.CharField(max_length=100)
110     evento = models.ForeignKey(Evento)
111
112     class Admin:
113         search_fields = 'nome',
114         list_filter = 'evento',
115
116     def __str__(self):
117         return self.nome
118
119 class Trabalho(models.Model):
120     titulo = models.CharField(max_length=100)
121     evento = models.ForeignKey(Evento)
122     tipo = models.ForeignKey(TipoTrabalho)
123     trilha = models.ForeignKey(Trilha)
124     palestrante = models.ForeignKey(Palestrante)
125     descricao_curta = models.TextField(u'Descrição curta')
126     descricao_longa = models.TextField(u'Descrição longa')
127     recursos = models.TextField(blank=True)
128     outros_palestrantes = \
129         models.ManyToManyField(Palestrante,
130                                related_name='outros_palestrantes',
131                                blank=True,
132                                null=True)
133
134     class Admin:
135         list_filter = 'evento', 'tipo', 'trilha',
136         search_fields = list_display = 'titulo', 'evento', 'tipo'
137
138     def __str__(self):
139         return self.titulo