From 3b3c12256f119c6e8a3486e09b699357c67f982d Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Wed, 7 Oct 2015 22:13:03 -0300 Subject: [PATCH] Created the Eventos app for register Interlegis events --- sigi/apps/eventos/__init__.py | 0 sigi/apps/eventos/admin.py | 52 ++++++++++++ sigi/apps/eventos/migrations/__init__.py | 0 sigi/apps/eventos/models.py | 103 +++++++++++++++++++++++ sigi/apps/eventos/tests.py | 3 + sigi/apps/eventos/views.py | 3 + sigi/settings/base.py | 1 + 7 files changed, 162 insertions(+) create mode 100644 sigi/apps/eventos/__init__.py create mode 100644 sigi/apps/eventos/admin.py create mode 100644 sigi/apps/eventos/migrations/__init__.py create mode 100644 sigi/apps/eventos/models.py create mode 100644 sigi/apps/eventos/tests.py create mode 100644 sigi/apps/eventos/views.py diff --git a/sigi/apps/eventos/__init__.py b/sigi/apps/eventos/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sigi/apps/eventos/admin.py b/sigi/apps/eventos/admin.py new file mode 100644 index 0000000..b38194d --- /dev/null +++ b/sigi/apps/eventos/admin.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# +# sigi.apps.eventos.admin +# +# Copyright (C) 2015 Interlegis +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +from django.utils.translation import ugettext as _ +from django.contrib import admin +from django.contrib.admin import register +from sigi.apps.eventos.models import TipoEvento, Funcao, Evento, Equipe, Convite + +@register(TipoEvento) +class TipoEventAdmin(admin.ModelAdmin): + search_fields = ('nome',) + +@register(Funcao) +class FuncaoAdmin(admin.ModelAdmin): + list_display = ('nome', 'descricao',) + search_fields = ('nome', 'descricao',) + +class EquipeInline(admin.TabularInline): + model = Equipe + +class ConviteInline(admin.TabularInline): + model = Convite + raw_id_fields = ('casa',) + +@register(Evento) +class EventoAdmin(admin.ModelAdmin): + date_hierarchy = 'data_inicio' + list_display = ('nome', 'tipo_evento', 'data_inicio', 'data_termino', 'municipio', 'solicitante') + list_filter = ('tipo_evento', 'municipio__uf', 'solicitante') + raw_id_fields = ('casa_anfitria', 'municipio',) + search_fields = ('nome', 'tipo_evento__nome', 'casa_anfitria__search_text', + 'municipio__search_text', 'solicitante') + inlines = (EquipeInline, ConviteInline) + + diff --git a/sigi/apps/eventos/migrations/__init__.py b/sigi/apps/eventos/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sigi/apps/eventos/models.py b/sigi/apps/eventos/models.py new file mode 100644 index 0000000..1a10395 --- /dev/null +++ b/sigi/apps/eventos/models.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +# +# sigi.apps.eventos.models +# +# Copyright (C) 2015 Interlegis +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +from django.db import models +from django.db.models import Q +from django.utils.translation import ugettext as _ +from sigi.apps.casas.models import CasaLegislativa +from sigi.apps.contatos.models import Municipio +from sigi.apps.servidores.models import Servidor +from sigi.apps.mdl.models import Course + +class TipoEvento(models.Model): + nome = models.CharField(_(u"Nome"), max_length=100) + + class Meta: + ordering = ("nome",) + verbose_name, verbose_name_plural = _(u"Tipo de evento"), _(u"Tipos de evento") + + def __unicode__(self): + return self.nome + +class Evento(models.Model): + tipo_evento = models.ForeignKey(TipoEvento) + nome = models.CharField(_(u"Nome do evento"), max_length=100) + solicitante = models.CharField(_(u"Solicitante"), max_length=100) + data_inicio = models.DateField(_(u"Data de início")) + data_termino = models.DateField(_(u"Data de término")) + casa_anfitria = models.ForeignKey(CasaLegislativa, verbose_name=_(u"Casa anfitriã"), blank=True, null=True) + municipio = models.ForeignKey(Municipio) + local = models.TextField(_(u"Local do evento"), blank=True) + curso_moodle_id = models.IntegerField(_(u"Curso saberes"), blank=True, null=True) + + class Meta: + ordering = ("-data_inicio",) + verbose_name, verbose_name_plural = _(u"Evento"), _(u"Eventos") + + def __unicode__(self): + return _("%(nome)s (%(tipo_evento)s): de %(data_inicio)s a %(data_termino)s") % dict( + nome=self.nome, + tipo_evento=unicode(self.tipo_evento), + data_inicio=self.data_inicio, + data_termino=self.data_termino) + + @property + def curso_moodle(self): + if self.curso_moodle_id: + return Course.objects.get(id=self.curso_moodle_id) + else: + return None + +class Funcao(models.Model): + nome = models.CharField(_(u"Função na equipe de evento"), max_length=100) + descricao = models.TextField(_(u"Descrição da função")) + + class Meta: + ordering = ("nome",) + verbose_name, verbose_name_plural = _(u"Função"), _(u"Funções") + + def __unicode__(self): + return self.nome + +class Equipe(models.Model): + evento = models.ForeignKey(Evento) + membro = models.ForeignKey(Servidor, related_name="equipe_evento") + funcao = models.ForeignKey(Funcao, verbose_name=_(u"Função na equipe")) + observacoes = models.TextField(_(u"Observações"), blank=True) + + class Meta: + ordering = ('evento', 'funcao', 'membro',) + verbose_name, verbose_name_plural = _(u"Membro da equipe"), _(u"Membros da equipe") + + def __unicode__(self): + return u"%s (%s)" % (unicode(self.membro), unicode(self.funcao),) + +class Convite(models.Model): + evento = models.ForeignKey(Evento) + casa = models.ForeignKey(CasaLegislativa, verbose_name=_(u"Casa convidada")) + servidor = models.ForeignKey(Servidor, verbose_name=_(u"Servidor que convidou")) + data_convite = models.DateField(_(u"Data do convite")) + aceite = models.BooleanField(_("Aceitou o convite"), default=False) + participou = models.BooleanField(_(u"Participou do evento"), default=False) + + class Meta: + ordering = ('evento', 'casa', '-data_convite') + unique_together = ('evento', 'casa') + verbose_name, verbose_name_plural = _(u"Casa convidada"), _(u"Casas convidadas") \ No newline at end of file diff --git a/sigi/apps/eventos/tests.py b/sigi/apps/eventos/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/sigi/apps/eventos/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/sigi/apps/eventos/views.py b/sigi/apps/eventos/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/sigi/apps/eventos/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/sigi/settings/base.py b/sigi/settings/base.py index a0f8c20..f454837 100644 --- a/sigi/settings/base.py +++ b/sigi/settings/base.py @@ -68,6 +68,7 @@ INSTALLED_APPS = ( 'sigi.apps.ocorrencias', 'sigi.apps.financeiro', 'sigi.apps.diagnosticos', + 'sigi.apps.eventos', # Integração com Saberes (moodle) 'sigi.apps.mdl',