From e7c1aa587929115a96f174d78ae3fe2b7ef99532 Mon Sep 17 00:00:00 2001 From: Mariana Mendes Date: Fri, 9 Mar 2018 08:47:52 -0300 Subject: [PATCH] Fix #1566 (#1739) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adiciona a model, forms e views da reunião de comissão * Adiciona telas de cadastro de reunião * Adiciona layouts e legacy * Adiciona template, modifica o subnav e o ListView * Troca Crud por MasterCrudDetail * Adiciona template de cadastro de reunião * Corrige Createview e Listview * Ajusta comissoes * Corrige o deleteview e o detailview * Muda o layout do create de reunião * - Retira o campo tipo de cadastro de reunião - Retira a obrigatoriedade do campo tema * Corrige migração --- sapl/comissoes/forms.py | 18 ++++-------- sapl/comissoes/legacy.yaml | 1 - .../migrations/0010_auto_20180307_1645.py | 29 +++++++++++++++++++ sapl/comissoes/migrations/0011_merge.py | 16 ++++++++++ sapl/comissoes/models.py | 12 ++------ sapl/materia/forms.py | 1 + sapl/templates/comissoes/layouts.yaml | 5 ++-- sapl/templates/comissoes/subnav.yaml | 1 + 8 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 sapl/comissoes/migrations/0010_auto_20180307_1645.py create mode 100644 sapl/comissoes/migrations/0011_merge.py diff --git a/sapl/comissoes/forms.py b/sapl/comissoes/forms.py index 33be2003d..a3414e755 100644 --- a/sapl/comissoes/forms.py +++ b/sapl/comissoes/forms.py @@ -10,6 +10,7 @@ from sapl.comissoes.models import Comissao, Composicao, Participacao, Reuniao from sapl.parlamentares.models import Legislatura, Mandato, Parlamentar + class ParticipacaoCreateForm(forms.ModelForm): parent_pk = forms.CharField(required=False) # widget=forms.HiddenInput()) @@ -154,20 +155,13 @@ class ReuniaoForm(ModelForm): class Meta: model = Reuniao exclude = ['cod_andamento_reuniao'] - widgets = { - 'hora_fim': forms.TimeInput(format='%H:%M'), - 'hora_inicio': forms.TimeInput(format='%H:%M'), - } def clean(self): super(ReuniaoForm, self).clean() - if self.errors: - return - - if self.cleaned_data['hora_fim'] < self.cleaned_data['hora_inicio']: - msg = _('A hora de término da reunião não pode ' - 'ser menor que a de início') - raise ValidationError(msg) - + if self.cleaned_data['hora_fim']: + if (self.cleaned_data['hora_fim'] < + self.cleaned_data['hora_inicio']): + msg = _('A hora de término da reunião não pode ser menor que a de início') + raise ValidationError(msg) return self.cleaned_data diff --git a/sapl/comissoes/legacy.yaml b/sapl/comissoes/legacy.yaml index 2414df885..59aacf503 100644 --- a/sapl/comissoes/legacy.yaml +++ b/sapl/comissoes/legacy.yaml @@ -47,7 +47,6 @@ Participacao (ComposicaoComissao): Reuniao: periodo: periodo_reuniao comissao: cod_comissao - tipo: tipo_comissao numero: num_comissao nome: nom_reuniao tema: tem_reuniao diff --git a/sapl/comissoes/migrations/0010_auto_20180307_1645.py b/sapl/comissoes/migrations/0010_auto_20180307_1645.py new file mode 100644 index 000000000..45b86bec4 --- /dev/null +++ b/sapl/comissoes/migrations/0010_auto_20180307_1645.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.13 on 2018-03-07 19:45 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('comissoes', '0009_auto_20180301_1011'), + ] + + operations = [ + migrations.RemoveField( + model_name='reuniao', + name='tipo', + ), + migrations.AlterField( + model_name='reuniao', + name='nome', + field=models.CharField(max_length=150, verbose_name='Nome da Reunião'), + ), + migrations.AlterField( + model_name='reuniao', + name='tema', + field=models.CharField(blank=True, max_length=150, verbose_name='Tema da Reunião'), + ), + ] diff --git a/sapl/comissoes/migrations/0011_merge.py b/sapl/comissoes/migrations/0011_merge.py new file mode 100644 index 000000000..a5a3c7b7a --- /dev/null +++ b/sapl/comissoes/migrations/0011_merge.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.13 on 2018-03-09 10:27 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('comissoes', '0010_auto_20180307_1645'), + ('comissoes', '0010_auto_20180306_0918'), + ] + + operations = [ + ] diff --git a/sapl/comissoes/models.py b/sapl/comissoes/models.py index 882fe8638..ed3cd3e50 100644 --- a/sapl/comissoes/models.py +++ b/sapl/comissoes/models.py @@ -182,15 +182,13 @@ class Participacao(models.Model): # ComposicaoComissao def get_comissao_media_path(instance, subpath, filename): return './sapl/comissao/%s/%s/%s' % (instance.numero, subpath, filename) - def pauta_upload_path(instance, filename): - return texto_upload_path(instance, filename, subpath='pauta', pk_first=True) + return texto_upload_path(instance, filename, subpath='pauta', pk_first=True) def ata_upload_path(instance, filename): return texto_upload_path(instance, filename, subpath='ata', pk_first=True) - def anexo_upload_path(instance, filename): return texto_upload_path(instance, filename, subpath='anexo', pk_first=True) @@ -204,15 +202,11 @@ class Reuniao(models.Model): Comissao, on_delete=models.PROTECT, verbose_name=_('Comissão')) - tipo = models.ForeignKey( - TipoComissao, - on_delete=models.PROTECT, - verbose_name=_('Tipo de Comissão')) numero = models.PositiveIntegerField(verbose_name=_('Número')) nome = models.CharField( - max_length=100, verbose_name=_('Nome da Reunião')) + max_length=150, verbose_name=_('Nome da Reunião')) tema = models.CharField( - max_length=100, verbose_name=_('Tema da Reunião')) + max_length=150, blank=True, verbose_name=_('Tema da Reunião')) data = models.DateField(verbose_name=_('Data')) hora_inicio = models.TimeField( verbose_name=_('Horário de Início (hh:mm)')) diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 1eebd5c7d..b6d74e970 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -1265,6 +1265,7 @@ class ProposicaoForm(forms.ModelForm): inst.texto_original.delete() self.gerar_hash(inst, receber_recibo) + return super().save(commit) inst.ano = timezone.now().year diff --git a/sapl/templates/comissoes/layouts.yaml b/sapl/templates/comissoes/layouts.yaml index 231477a9c..5d0026ba2 100644 --- a/sapl/templates/comissoes/layouts.yaml +++ b/sapl/templates/comissoes/layouts.yaml @@ -46,11 +46,10 @@ ParticipacaoEdit: Reuniao: {% trans 'Reunião' %}: - - periodo numero tipo + - periodo numero - nome tema local_reuniao - data hora_inicio hora_fim - url_video url_audio - observacao - upload_pauta upload_ata upload_anexo - - comissao - + - comissao \ No newline at end of file diff --git a/sapl/templates/comissoes/subnav.yaml b/sapl/templates/comissoes/subnav.yaml index 01c10b4f3..e7e49837b 100644 --- a/sapl/templates/comissoes/subnav.yaml +++ b/sapl/templates/comissoes/subnav.yaml @@ -8,3 +8,4 @@ url: materias_em_tramitacao - title: {% trans 'Reunião' %} url: reuniao_list +