From 0b63d7c4ecf0294d79561538a1d6abf64c9b0bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Mon, 10 May 2021 11:38:15 -0300 Subject: [PATCH] =?UTF-8?q?Bug=20na=20exporta=C3=A7=C3=A3o=20de=20convenio?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/convenios/admin.py | 30 +--- .../templates/convenios/carrinho.html | 170 +++++++++--------- sigi/apps/convenios/views.py | 25 ++- 3 files changed, 115 insertions(+), 110 deletions(-) diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index 601079d..ad4d7bc 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -110,28 +110,16 @@ class ConvenioAdmin(BaseModelAdmin): link_sigad.allow_tags = True def changelist_view(self, request, extra_context=None): - def normaliza_data(nome_param): - import re - if nome_param in request.GET: - value = request.GET.get(nome_param, '') - if value == '': - del request.GET[nome_param] - elif re.match('^\d*$', value): # Year only - # Complete with january 1st - request.GET[nome_param] = "%s-01-01" % value - elif re.match('^\d*\D\d*$', value): # Year and month - # Complete with 1st day of month - request.GET[nome_param] = '%s-01' % value - + from sigi.apps.convenios.views import normaliza_data request.GET._mutable = True - normaliza_data('data_retorno_assinatura__gte') - normaliza_data('data_retorno_assinatura__lte') - normaliza_data('data_sigad__gte') - normaliza_data('data_sigad__lte') - normaliza_data('data_sigi__gte') - normaliza_data('data_sigi__lte') - normaliza_data('data_solicitacao__gte') - normaliza_data('data_solicitacao__lte') + normaliza_data(request.GET, 'data_retorno_assinatura__gte') + normaliza_data(request.GET, 'data_retorno_assinatura__lte') + normaliza_data(request.GET, 'data_sigad__gte') + normaliza_data(request.GET, 'data_sigad__lte') + normaliza_data(request.GET, 'data_sigi__gte') + normaliza_data(request.GET, 'data_sigi__lte') + normaliza_data(request.GET, 'data_solicitacao__gte') + normaliza_data(request.GET, 'data_solicitacao__lte') request.GET._mutable = False return super(ConvenioAdmin, self).changelist_view( diff --git a/sigi/apps/convenios/templates/convenios/carrinho.html b/sigi/apps/convenios/templates/convenios/carrinho.html index 9e8cae8..e80c224 100644 --- a/sigi/apps/convenios/templates/convenios/carrinho.html +++ b/sigi/apps/convenios/templates/convenios/carrinho.html @@ -21,8 +21,8 @@ {% block action %}deleta_itens_carrinho{% endblock %} {% block tabela %} - - +
+ {%if not carIsEmpty%} {% for convenio in paginas.object_list %} - + {%if not carIsEmpty%} @@ -56,107 +56,103 @@ {% endblock %} {% block botoes %} -
- - -
-
{% csrf_token %} -
- {% trans 'Relatório por' %} -
    -
  • - - -
  • -
  • - - -
  • -
  • - - -
  • -
+ +
+
+ {% csrf_token %} +
+ {% trans 'Relatório por' %} +
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
{% trans 'Com data de aceite? (Equipada)' %}
  • - - -
  • + + +
  • - - -
  • + + +
-
    -
  • -
- + +
-
+
{% csrf_token %} -
{% trans 'Escolha os atributos para exportar' %} -
    -
  • - - + {% trans 'Escolha os atributos para exportar' %} +
      +
    • + + - -
    • -
    • - - {% trans 'Nº Processo' %} +
    • +
    • + + - -
    • -
    • - - {% trans 'Nº Convênio' %} +
    • +
    • + + - -
    • -
    • - - {% trans 'Projeto' %} +
    • +
    • + + - -
    • -
    • - - {% trans 'Casa Legislativa' %} +
    • +
    • + + - -
    • -
    • - - {% trans 'Data de Adesão' %} +
    • +
    • + + - -
    • -
    • - - {% trans 'Data de Convênio' %} +
    • +
    • + + - -
    • -
    • - - {% trans 'Data da Publicação no Diário Oficial' %} +
    • +
    • + + - -
    • -
    -
-
    -
  • -
- -
+ + + +
+ + +
{% endblock %} diff --git a/sigi/apps/convenios/views.py b/sigi/apps/convenios/views.py index 3ae3e97..d9ae58f 100644 --- a/sigi/apps/convenios/views.py +++ b/sigi/apps/convenios/views.py @@ -36,10 +36,32 @@ def query_ordena(qs, o, ot): qs = qs.order_by("-" + aux) return qs +def normaliza_data(get, nome_param): + import re + if nome_param in get: + value = get.get(nome_param, '') + if value == '': + del get[nome_param] + elif re.match('^\d*$', value): # Year only + # Complete with january 1st + get[nome_param] = "%s-01-01" % value + elif re.match('^\d*\D\d*$', value): # Year and month + # Complete with 1st day of month + get[nome_param] = '%s-01' % value def get_for_qs(get, qs): kwargs = {} ids = 0 + get._mutable = True + normaliza_data(get, 'data_retorno_assinatura__gte') + normaliza_data(get, 'data_retorno_assinatura__lte') + normaliza_data(get, 'data_sigad__gte') + normaliza_data(get, 'data_sigad__lte') + normaliza_data(get, 'data_sigi__gte') + normaliza_data(get, 'data_sigi__lte') + normaliza_data(get, 'data_solicitacao__gte') + normaliza_data(get, 'data_solicitacao__lte') + get._mutable = False for k, v in get.iteritems(): if k not in ['page', 'pop', 'q', '_popup']: if not k == 'o': @@ -50,8 +72,7 @@ def get_for_qs(get, qs): if(str(k) == 'ids'): ids = 1 break - qs = qs.filter(**kwargs) - + qs = qs.filter(**kwargs) if ids: query = 'id IN (' + kwargs['ids'].__str__() + ')' qs = Convenio.objects.extra(where=[query])
@@ -38,7 +38,7 @@