diff --git a/sigi/apps/casas/views.py b/sigi/apps/casas/views.py index 741786d..70efb65 100644 --- a/sigi/apps/casas/views.py +++ b/sigi/apps/casas/views.py @@ -271,8 +271,8 @@ class importa_casas(View): self.errors.append(reg) continue elif orgao.count() > 1: - reg[self.ERROS].append("Existem {count} orgaos com esta mesma " - "identificacao").format(count=orgao.count()) + reg[self.ERROS].append(("Existem {count} orgaos com esta mesma " + "identificacao").format(count=orgao.count())) self.errors.append(reg) continue else: diff --git a/sigi/apps/eventos/admin.py b/sigi/apps/eventos/admin.py index 858c5f3..2594d43 100644 --- a/sigi/apps/eventos/admin.py +++ b/sigi/apps/eventos/admin.py @@ -78,7 +78,7 @@ class AnexoInline(admin.TabularInline): class EventoAdmin(admin.ModelAdmin): form = EventoAdminForm date_hierarchy = 'data_inicio' - list_display = ('nome', 'tipo_evento', 'status', 'link_sigad', + list_display = ('nome', 'tipo_evento', 'turma', 'status', 'link_sigad', 'data_inicio', 'data_termino', 'municipio', 'solicitante', 'total_participantes',) list_filter = ('status', SigadFilter, 'tipo_evento', diff --git a/sigi/apps/eventos/forms.py b/sigi/apps/eventos/forms.py index c752499..2903a69 100644 --- a/sigi/apps/eventos/forms.py +++ b/sigi/apps/eventos/forms.py @@ -7,11 +7,11 @@ from sigi.apps.eventos.models import ModeloDeclaracao, Evento class EventoAdminForm(forms.ModelForm): class Meta: model = Evento - fields = ('tipo_evento', 'nome', 'descricao', 'virtual', 'solicitante', - 'num_processo', 'data_pedido', 'data_inicio', 'data_termino', - 'carga_horaria', 'casa_anfitria', 'municipio', 'observacao', - 'local', 'publico_alvo', 'total_participantes', 'status', - 'data_cancelamento', 'motivo_cancelamento', ) + fields = ('tipo_evento', 'nome', 'turma', 'descricao', 'virtual', + 'solicitante', 'num_processo', 'data_pedido', 'data_inicio', + 'data_termino', 'carga_horaria', 'casa_anfitria', 'municipio', + 'observacao', 'local', 'publico_alvo', 'total_participantes', + 'status', 'data_cancelamento', 'motivo_cancelamento', ) def clean(self): cleaned_data = super(EventoAdminForm, self).clean() diff --git a/sigi/apps/eventos/migrations/0018_evento_turma.py b/sigi/apps/eventos/migrations/0018_evento_turma.py new file mode 100644 index 0000000..2546056 --- /dev/null +++ b/sigi/apps/eventos/migrations/0018_evento_turma.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('eventos', '0017_auto_20220413_0900'), + ] + + operations = [ + migrations.AddField( + model_name='evento', + name='turma', + field=models.CharField(max_length=100, verbose_name='Turma', blank=True), + preserve_default=True, + ), + ] diff --git a/sigi/apps/eventos/migrations/0019_auto_20220808_1037.py b/sigi/apps/eventos/migrations/0019_auto_20220808_1037.py new file mode 100644 index 0000000..7bf009c --- /dev/null +++ b/sigi/apps/eventos/migrations/0019_auto_20220808_1037.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + +def separa_turma(apps, schema_editor): + Evento = apps.get_model("eventos", "Evento") + for evento in Evento.objects.filter(nome__icontains='Turma'): + split_name = evento.nome.rsplit('-', 1) + if len(split_name) == 2: + evento.nome = split_name[0].strip() + evento.turma = split_name[1].strip() + evento.save() + +def junta_turma(apps, schema_editor): + Evento = apps.get_model("eventos", "Evento") + for evento in Evento.objects.exclude(turma=''): + evento.nome = evento.nome + ' - ' + evento.turma + evento.save() + +class Migration(migrations.Migration): + + dependencies = [ + ('eventos', '0018_evento_turma'), + ] + + operations = [ + migrations.RunPython(separa_turma, junta_turma), + ] diff --git a/sigi/apps/eventos/models.py b/sigi/apps/eventos/models.py index 853fe4e..59f4d76 100644 --- a/sigi/apps/eventos/models.py +++ b/sigi/apps/eventos/models.py @@ -52,6 +52,7 @@ class Evento(models.Model): on_delete=models.PROTECT, ) nome = models.CharField(_(u"Nome do evento"), max_length=100) + turma = models.CharField(_(u"Turma"), max_length=100, blank=True) descricao = models.TextField(_(u"Descrição do evento")) virtual = models.BooleanField(_("Virtual"), default=False) solicitante = models.CharField(_(u"Solicitante"), max_length=100)