f1378f42fa7f0f088251d506eda025668a406e27
[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     cidade = models.CharField(max_length=100)
31     estado = models.CharField(max_length=2, choices=STATE_CHOICES)
32     rua = models.CharField(max_length=100)
33     numero = models.CharField(u'Número', max_length=10)
34     info_adicional = models.TextField(blank=True)
35
36     class Admin:
37         fields = (
38             (u'Informações do evento',
39              {'fields': ('nome', 'data_inicio', 'data_final')}),
40
41             (u'Informações da sede',
42              {'fields': ('local', 'nome_contato', 'rua', 'numero', 'cidade',
43                          'estado', 'telefone', 'info_adicional')}),
44         )
45
46         search_fields = list_display = 'nome', 'local'
47
48     def __str__(self):
49         return self.nome
50
51 class Palestrante(models.Model):
52     nome = models.CharField(max_length=100)
53     email = models.CharField(max_length=100)
54
55     telefone = models.CharField(max_length=100, blank=True)
56     celular = models.CharField(max_length=100, blank=True)
57
58     instituicao = models.CharField(u'Instituição', max_length=250, blank=True)
59
60     rua = models.CharField(max_length=100)
61     numero = models.CharField(u'Número', max_length=10)
62     bairro = models.CharField(max_length=100)
63     cidade = models.CharField(max_length=100)
64     estado = models.CharField(max_length=2, choices=STATE_CHOICES)
65
66     minicurriculo = models.TextField(u'Mini currículo')
67     curriculo = models.TextField(u'Currículo')
68
69     usuario = models.ForeignKey(User, help_text=u'Este campo associa o '
70                                 'palestrante a uma conta no sistema para '
71                                 'que ele possa enviar trabalhos e alterar '
72                                 'dados pessoais.')
73
74     class Admin:
75         fields = (
76             (None, {'fields': ('nome', 'email', 'instituicao',
77                                'minicurriculo', 'curriculo')}),
78
79             (u'Telefones', {'fields': ('telefone', 'celular')}),
80
81             (u'Endereço', {'fields': ('rua', 'numero',
82                                       'bairro', '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
96     class Admin:
97         search_fields = 'nome',
98
99     class Meta:
100         verbose_name = u'Tipo de trabalho'
101         verbose_name_plural = u'Tipos de trabalho'
102
103     def __str__(self):
104         return self.nome
105
106 class Trabalho(models.Model):
107     titulo = models.CharField(max_length=100)
108     evento = models.ForeignKey(Evento)
109     tipo = models.ForeignKey(TipoTrabalho)
110     palestrante = models.ForeignKey(Palestrante)
111     descricao_curta = models.TextField(u'Descrição curta')
112     descricao_longa = models.TextField(u'Descrição longa')
113     recursos = models.TextField(blank=True)
114     outros_palestrantes = \
115         models.ManyToManyField(Palestrante,
116                                related_name='outros_palestrantes',
117                                blank=True,
118                                null=True)
119
120     class Admin:
121         list_filter = 'evento', 'tipo'
122         search_fields = list_display = 'titulo', 'evento', 'tipo'
123
124     def __str__(self):
125         return self.titulo