From 7f90bd7770f07b0d6398f934a4a8cf5dc6fb9b97 Mon Sep 17 00:00:00 2001 From: Cesar Augusto de Carvalho Date: Mon, 15 Apr 2019 16:51:22 -0300 Subject: [PATCH] =?UTF-8?q?Fix=202711=20-=20Adiciona=20op=C3=A7=C3=A3o=20d?= =?UTF-8?q?e=20numera=C3=A7=C3=A3o=20por=20ano=20independentemente=20do=20?= =?UTF-8?q?autor=20(#2725)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0033_auto_20190415_1050.py | 20 +++++++++++++++++++ sapl/base/models.py | 3 ++- sapl/materia/forms.py | 13 ++++++++---- .../migrations/0045_auto_20190415_1050.py | 20 +++++++++++++++++++ 4 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 sapl/base/migrations/0033_auto_20190415_1050.py create mode 100644 sapl/materia/migrations/0045_auto_20190415_1050.py diff --git a/sapl/base/migrations/0033_auto_20190415_1050.py b/sapl/base/migrations/0033_auto_20190415_1050.py new file mode 100644 index 000000000..8c21764f3 --- /dev/null +++ b/sapl/base/migrations/0033_auto_20190415_1050.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-04-15 13:50 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0032_merge_20190219_0941'), + ] + + operations = [ + migrations.AlterField( + model_name='appconfig', + name='sequencia_numeracao', + field=models.CharField(choices=[('A', 'Sequencial por ano para cada autor'), ('B', 'Sequencial por ano indepententemente do autor'), ('L', 'Sequencial por legislatura'), ('U', 'Sequencial único')], default='A', max_length=1, verbose_name='Sequência de numeração'), + ), + ] diff --git a/sapl/base/models.py b/sapl/base/models.py index 87e497e84..b4f0a8d74 100644 --- a/sapl/base/models.py +++ b/sapl/base/models.py @@ -18,7 +18,8 @@ TIPO_DOCUMENTO_ADMINISTRATIVO = ((DOC_ADM_OSTENSIVO, _('Ostensiva')), RELATORIO_ATOS_ACESSADOS = (('S', _('Sim')), ('N', _('Não'))) -SEQUENCIA_NUMERACAO = (('A', _('Sequencial por ano')), +SEQUENCIA_NUMERACAO = (('A', _('Sequencial por ano para cada autor')), + ('B', _('Sequencial por ano indepententemente do autor')), ('L', _('Sequencial por legislatura')), ('U', _('Sequencial único'))) diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 6a6f59300..41f3b550a 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -1666,12 +1666,17 @@ class ProposicaoForm(FileFieldCheckMixin, forms.ModelForm): return super().save(commit) inst.ano = timezone.now().year - numero__max = Proposicao.objects.filter( - autor=inst.autor, - ano=timezone.now().year).aggregate(Max('numero_proposicao')) + sequencia_numeracao = AppConfig.attr('sequencia_numeracao') + if sequencia_numeracao == 'A': + numero__max = Proposicao.objects.filter( + autor=inst.autor, + ano=timezone.now().year).aggregate(Max('numero_proposicao')) + elif sequencia_numeracao == 'B': + numero__max = Proposicao.objects.filter( + ano=timezone.now().year).aggregate(Max('numero_proposicao')) numero__max = numero__max['numero_proposicao__max'] inst.numero_proposicao = ( - numero__max + 1) if numero__max else 1 + numero__max + 1) if numero__max else 1 self.gerar_hash(inst, receber_recibo) diff --git a/sapl/materia/migrations/0045_auto_20190415_1050.py b/sapl/materia/migrations/0045_auto_20190415_1050.py new file mode 100644 index 000000000..55f59dd49 --- /dev/null +++ b/sapl/materia/migrations/0045_auto_20190415_1050.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-04-15 13:50 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('materia', '0044_auto_20190327_1409'), + ] + + operations = [ + migrations.AlterField( + model_name='tipomaterialegislativa', + name='sequencia_numeracao', + field=models.CharField(blank=True, choices=[('A', 'Sequencial por ano para cada autor'), ('B', 'Sequencial por ano indepententemente do autor'), ('L', 'Sequencial por legislatura'), ('U', 'Sequencial único')], max_length=1, verbose_name='Sequência de numeração'), + ), + ]