X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fema.git;a=blobdiff_plain;f=eventos%2Fmodels.py;h=c5d9d840b6df3c1c4803d90b527411fa55173417;hp=73aacea683486756e92c5b038d8a0e710b7929bd;hb=41b21b3775106ca5c928660ec62da6397283d229;hpb=78fc1d06732ed7744faff33e97bf3a7aadc508af diff --git a/eventos/models.py b/eventos/models.py index 73aacea..c5d9d84 100644 --- a/eventos/models.py +++ b/eventos/models.py @@ -18,6 +18,7 @@ from django.db import models from django.contrib.localflavor.br.br_states import STATE_CHOICES from django.contrib.auth.models import User +from django.contrib.sites.models import Site class Evento(models.Model): nome = models.CharField(max_length=100) @@ -27,19 +28,20 @@ class Evento(models.Model): local = models.CharField(max_length=100) nome_contato = models.CharField(u'Nome do contato', max_length=100) telefone = models.CharField(max_length=100) + endereco = models.TextField() cidade = models.CharField(max_length=100) estado = models.CharField(max_length=2, choices=STATE_CHOICES) - rua = models.CharField(max_length=100) - numero = models.CharField(u'Número', max_length=10) info_adicional = models.TextField(blank=True) + site = models.ForeignKey(Site) + class Admin: fields = ( (u'Informações do evento', - {'fields': ('nome', 'data_inicio', 'data_final')}), + {'fields': ('nome', 'data_inicio', 'data_final', 'site')}), (u'Informações da sede', - {'fields': ('local', 'nome_contato', 'rua', 'numero', 'cidade', + {'fields': ('local', 'nome_contato', 'endereco', 'cidade', 'estado', 'telefone', 'info_adicional')}), ) @@ -57,9 +59,8 @@ class Palestrante(models.Model): instituicao = models.CharField(u'Instituição', max_length=250, blank=True) - rua = models.CharField(max_length=100) - numero = models.CharField(u'Número', max_length=10) - bairro = models.CharField(max_length=100) + endereco = models.TextField() + cep = models.CharField(max_length=8) cidade = models.CharField(max_length=100) estado = models.CharField(max_length=2, choices=STATE_CHOICES) @@ -78,8 +79,7 @@ class Palestrante(models.Model): (u'Telefones', {'fields': ('telefone', 'celular')}), - (u'Endereço', {'fields': ('rua', 'numero', - 'bairro', 'cidade', 'estado')}), + (u'Endereço', {'fields': ('endereco', 'cep', 'cidade', 'estado')}), (u'Avançado', {'fields': ('usuario',), 'classes': 'collapse'}), @@ -92,9 +92,11 @@ class Palestrante(models.Model): class TipoTrabalho(models.Model): nome = models.CharField(max_length=100) + evento = models.ForeignKey(Evento) class Admin: search_fields = 'nome', + list_filter = 'evento', class Meta: verbose_name = u'Tipo de trabalho' @@ -103,17 +105,34 @@ class TipoTrabalho(models.Model): def __str__(self): return self.nome +class Trilha(models.Model): + nome = models.CharField(max_length=100) + evento = models.ForeignKey(Evento) + + class Admin: + search_fields = 'nome', + list_filter = 'evento', + + def __str__(self): + return self.nome + class Trabalho(models.Model): titulo = models.CharField(max_length=100) evento = models.ForeignKey(Evento) tipo = models.ForeignKey(TipoTrabalho) - palestrante = models.ManyToManyField(Palestrante) + trilha = models.ForeignKey(Trilha) + palestrante = models.ForeignKey(Palestrante) descricao_curta = models.TextField(u'Descrição curta') descricao_longa = models.TextField(u'Descrição longa') recursos = models.TextField(blank=True) + outros_palestrantes = \ + models.ManyToManyField(Palestrante, + related_name='outros_palestrantes', + blank=True, + null=True) class Admin: - list_filter = 'evento', 'tipo' + list_filter = 'evento', 'tipo', 'trilha', search_fields = list_display = 'titulo', 'evento', 'tipo' def __str__(self):