From 9baa64df32472945cbc224997bf9fdc183fa8c37 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Tue, 22 Oct 2019 12:11:44 -0300 Subject: [PATCH] Remove import ipdb, adiciona logica a protocolo de materia --- sapl/protocoloadm/views.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py index 4bd6abb8a..c954413f5 100755 --- a/sapl/protocoloadm/views.py +++ b/sapl/protocoloadm/views.py @@ -542,7 +542,6 @@ class ProtocoloDocumentoView(PermissionRequiredMixin, @transaction.atomic def form_valid(self, form): - import ipdb; ipdb.set_trace() protocolo = form.save(commit=False) username = self.request.user.username @@ -773,10 +772,22 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView): data_fim__year__gte=timezone.now().year).first() data_inicio = legislatura.data_inicio data_fim = legislatura.data_fim + + data_inicio_utc = from_date_to_datetime_utc(data_inicio) + data_fim_utc = from_date_to_datetime_utc(data_fim) + numero = Protocolo.objects.filter( - data__gte=data_inicio, - data__lte=data_fim).aggregate( - Max('numero')) + Q(data__isnull=False, + data__gte=data_inicio, + data__lte=data_fim) | + Q(timestamp__isnull=False, + timestamp__gte=data_inicio_utc, + timestamp__lte=data_fim_utc) | + Q(timestamp_data_hora_manual__isnull=False, + timestamp_data_hora_manual__gte=data_inicio_utc, + timestamp_data_hora_manual__lte=data_fim_utc,)).\ + aggregate(Max('numero')) + elif numeracao == 'U': numero = Protocolo.objects.all().aggregate(Max('numero'))