From aaf8986965c5056b3d7b00215141d46bbcb7b38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Sat, 17 Apr 2021 09:48:02 -0300 Subject: [PATCH] Fix #23 --- sigi/apps/eventos/admin.py | 42 ++++++++++--------- .../migrations/0007_auto_20210417_0744.py | 38 +++++++++++++++++ sigi/apps/eventos/models.py | 14 +++++++ 3 files changed, 74 insertions(+), 20 deletions(-) create mode 100644 sigi/apps/eventos/migrations/0007_auto_20210417_0744.py diff --git a/sigi/apps/eventos/admin.py b/sigi/apps/eventos/admin.py index 94c6c58..088d82c 100644 --- a/sigi/apps/eventos/admin.py +++ b/sigi/apps/eventos/admin.py @@ -3,17 +3,17 @@ # 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. @@ -26,19 +26,22 @@ from sigi.apps.eventos.models import TipoEvento, Funcao, Evento, Equipe, Convite class EventoAdminForm(forms.ModelForm): class Meta: model = Evento - fields = ('tipo_evento', 'nome', 'descricao', 'solicitante', 'data_inicio', 'data_termino', - 'casa_anfitria', 'municipio', 'local', 'publico_alvo', 'status', - 'data_cancelamento', 'motivo_cancelamento', ) - + fields = ('tipo_evento', 'nome', 'descricao', 'virtual', 'solicitante', + 'data_inicio', 'data_termino', 'carga_horaria', + 'casa_anfitria', 'municipio', 'local', 'publico_alvo', + 'status', 'data_cancelamento', 'motivo_cancelamento', ) + def clean(self): cleaned_data = super(EventoAdminForm, self).clean() data_inicio = cleaned_data.get("data_inicio") data_termino = cleaned_data.get("data_termino") - + if data_inicio > data_termino: - raise forms.ValidationError(_(u"Data término deve ser posterior à data inicio"), - code="invalid_period" ) - + raise forms.ValidationError( + _(u"Data término deve ser posterior à data inicio"), + code="invalid_period" + ) + @admin.register(TipoEvento) class TipoEventAdmin(admin.ModelAdmin): search_fields = ('nome',) @@ -47,24 +50,23 @@ class TipoEventAdmin(admin.ModelAdmin): 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',) @admin.register(Evento) class EventoAdmin(admin.ModelAdmin): - form = EventoAdminForm + form = EventoAdminForm date_hierarchy = 'data_inicio' - list_display = ('nome', 'tipo_evento', 'status', 'data_inicio', 'data_termino', 'municipio', - 'solicitante') - list_filter = ('status', 'tipo_evento', 'municipio__uf', 'solicitante') + list_display = ('nome', 'tipo_evento', 'status', 'data_inicio', + 'data_termino', 'municipio', 'solicitante') + list_filter = ('status', 'tipo_evento', 'virtual', '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) - - + inlines = (EquipeInline, ConviteInline) \ No newline at end of file diff --git a/sigi/apps/eventos/migrations/0007_auto_20210417_0744.py b/sigi/apps/eventos/migrations/0007_auto_20210417_0744.py new file mode 100644 index 0000000..e00c563 --- /dev/null +++ b/sigi/apps/eventos/migrations/0007_auto_20210417_0744.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('eventos', '0006_auto_20210416_0841'), + ] + + operations = [ + migrations.AddField( + model_name='convite', + name='nomes_participantes', + field=models.TextField(help_text='Favor colocar um participante por linha', verbose_name='nome dos participantes', blank=True), + preserve_default=True, + ), + migrations.AddField( + model_name='convite', + name='qtde_participantes', + field=models.PositiveIntegerField(default=0, verbose_name='n\xfamero de participantes'), + preserve_default=True, + ), + migrations.AddField( + model_name='evento', + name='carga_horaria', + field=models.PositiveIntegerField(default=0, verbose_name='carga hor\xe1ria'), + preserve_default=True, + ), + migrations.AddField( + model_name='evento', + name='virtual', + field=models.BooleanField(default=False, verbose_name='Virtual'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/eventos/models.py b/sigi/apps/eventos/models.py index 8fc11c2..3fcb85f 100644 --- a/sigi/apps/eventos/models.py +++ b/sigi/apps/eventos/models.py @@ -33,9 +33,14 @@ class Evento(models.Model): ) nome = models.CharField(_(u"Nome do evento"), max_length=100) descricao = models.TextField(_(u"Descrição do evento")) + virtual = models.BooleanField(_("Virtual"), default=False) 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")) + carga_horaria = models.PositiveIntegerField( + _(u"carga horária"), + default=0 + ) casa_anfitria = models.ForeignKey( Orgao, on_delete=models.PROTECT, @@ -125,6 +130,15 @@ class Convite(models.Model): 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) + qtde_participantes = models.PositiveIntegerField( + _(u"número de participantes"), + default=0 + ) + nomes_participantes = models.TextField( + _(u"nome dos participantes"), + blank=True, + help_text=_(u"Favor colocar um participante por linha") + ) class Meta: ordering = ('evento', 'casa', '-data_convite')