From 28b0b3e39baa1796000ede5b217e2e2cbbbec376 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Mon, 10 Jun 2019 13:01:23 -0300 Subject: [PATCH] =?UTF-8?q?refatora=20=5F=5Fstr=5F=5F=20de=20sess=C3=A3o?= =?UTF-8?q?=20plen=C3=A1ria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...607_1548.py => 0041_auto_20190610_1300.py} | 4 +- sapl/sessao/models.py | 42 +++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) rename sapl/sessao/migrations/{0041_auto_20190607_1548.py => 0041_auto_20190610_1300.py} (66%) diff --git a/sapl/sessao/migrations/0041_auto_20190607_1548.py b/sapl/sessao/migrations/0041_auto_20190610_1300.py similarity index 66% rename from sapl/sessao/migrations/0041_auto_20190607_1548.py rename to sapl/sessao/migrations/0041_auto_20190610_1300.py index fab885742..81ceaea06 100644 --- a/sapl/sessao/migrations/0041_auto_20190607_1548.py +++ b/sapl/sessao/migrations/0041_auto_20190610_1300.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.11.20 on 2019-06-07 18:48 +# Generated by Django 1.11.20 on 2019-06-10 16:00 from __future__ import unicode_literals from django.db import migrations, models @@ -15,7 +15,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='tiposessaoplenaria', name='tipo_numeracao', - field=models.PositiveIntegerField(choices=[(1, 'Anual'), (2, 'Mensal'), (3, 'Quinzenal'), (10, 'Sessão Legislativa'), (11, 'Legislatura'), (99, 'Numeração Única')], default=1, verbose_name='Tipo de Numeração'), + field=models.PositiveIntegerField(choices=[(1, 'Quinzenal'), (2, 'Mensal'), (10, 'Anual'), (11, 'Sessão Legislativa'), (12, 'Legislatura'), (99, 'Numeração Única')], default=10, verbose_name='Tipo de Numeração'), ), migrations.AlterField( model_name='tiposessaoplenaria', diff --git a/sapl/sessao/models.py b/sapl/sessao/models.py index 72e0eb3a5..1fef08f6d 100644 --- a/sapl/sessao/models.py +++ b/sapl/sessao/models.py @@ -3,7 +3,7 @@ from operator import xor from django.core.exceptions import ValidationError from django.db import models from django.db.models import Q -from django.utils import timezone +from django.utils import timezone, formats from django.utils.translation import ugettext_lazy as _ from model_utils import Choices import reversion @@ -76,11 +76,11 @@ class Bancada(models.Model): class TipoSessaoPlenaria(models.Model): TIPO_NUMERACAO_CHOICES = Choices( - (1, 'anual', 'Anual'), + (1, 'quizenal', 'Quinzenal'), (2, 'mensal', 'Mensal'), - (3, 'quizenal', 'Quinzenal'), - (10, 'sessao_legislativa', 'Sessão Legislativa'), - (11, 'legislatura', 'Legislatura'), + (10, 'anual', 'Anual'), + (11, 'sessao_legislativa', 'Sessão Legislativa'), + (12, 'legislatura', 'Legislatura'), (99, 'unica', 'Numeração Única'), ) @@ -90,7 +90,7 @@ class TipoSessaoPlenaria(models.Model): tipo_numeracao = models.PositiveIntegerField( verbose_name=_('Tipo de Numeração'), - choices=TIPO_NUMERACAO_CHOICES, default=1) + choices=TIPO_NUMERACAO_CHOICES, default=10) class Meta: verbose_name = _('Tipo de Sessão Plenária') @@ -214,7 +214,34 @@ class SessaoPlenaria(models.Model): verbose_name_plural = _('Sessões Plenárias') def __str__(self): - return _('%(numero)sª Sessão %(tipo_nome)s' + + tnc = self.tipo.TIPO_NUMERACAO_CHOICES + + base = '{}ª {}'.format(self.numero, self.tipo.nome) + + if self.tipo.tipo_numeracao == tnc.quizenal: + base += ' da {}ª Quinzena'.format( + 1 if self.data_inicio.day > 15 else 2) + + if self.tipo.tipo_numeracao <= tnc.mensal: + base += ' do mês de {}'.format( + formats.date_format(self.data_inicio, 'F') + ) + + if self.tipo.tipo_numeracao <= tnc.anual: + base += ' de {}'.format(self.data_inicio.year) + + if self.tipo.tipo_numeracao <= tnc.sessao_legislativa: + base += ' da {}ª Sessão Legislativa'.format( + self.sessao_legislativa.numero) + + if self.tipo.tipo_numeracao <= tnc.legislatura: + base += ' da {}ª Legislatura'.format( + self.legislatura.numero) + + return base + + """return _('%(numero)sª Sessão %(tipo_nome)s' ' da %(sessao_legislativa_numero)sª Sessão Legislativa' ' da %(legislatura_id)sª Legislatura') % { @@ -223,6 +250,7 @@ class SessaoPlenaria(models.Model): 'sessao_legislativa_numero': self.sessao_legislativa.numero, # XXX check if it shouldn't be legislatura.numero 'legislatura_id': self.legislatura.numero} + """ def delete(self, using=None, keep_parents=False): if self.upload_pauta: