Browse Source

Bug na exportação de convenios

pull/66/head
Sesostris Vieira 4 years ago
parent
commit
0b63d7c4ec
  1. 30
      sigi/apps/convenios/admin.py
  2. 170
      sigi/apps/convenios/templates/convenios/carrinho.html
  3. 25
      sigi/apps/convenios/views.py

30
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(

170
sigi/apps/convenios/templates/convenios/carrinho.html

@ -21,8 +21,8 @@
{% block action %}deleta_itens_carrinho{% endblock %}
{% block tabela %}
<table>
<thead>
<table class="table table-striped">
<thead class="thead-dark">
<tr>
{%if not carIsEmpty%}
<th class="sorted ascending"><!-- <input type="checkbox" id="action-toggle" style="display: inline;">-->
@ -38,7 +38,7 @@
</thead>
<tbody>
{% for convenio in paginas.object_list %}
<tr class="{% cycle 'row1' 'row2' %}">
<tr>
{%if not carIsEmpty%}
<th><input type="checkbox" name="_selected_action"
value="{{convenio.id|safe}}" class="action-select" /></th>
@ -56,107 +56,103 @@
{% endblock %}
{% block botoes %}
<div id="tabs">
<ul>
<li><a href="#tabs-1">{% trans 'Relatório' %}</a></li>
<li><a href="#tabs-2">{% trans 'Arquivo CSV (Excel, Calc)' %}</a></li>
</ul>
<div id="tabs-1">
<form action="../reports/{{ query_str }}" method="post">{% csrf_token %}
<fieldset>
<legend>{% trans 'Relatório por' %}</legend>
<ul class="tabs-conteudo">
<li>
<input type="radio" name="filtro_casa" value="tudo" checked="checked"/>
<label>{% trans 'Todos' %}</label>
</li>
<li>
<input type="radio" name="filtro_casa" value="cm"/>
<label>{% trans 'Câmara Municipal' %}</label>
</li>
<li>
<input type="radio" name="filtro_casa" value="al" />
<label>{% trans 'Assembléia Legislativa' %}</label>
</li>
</ul>
<ul class="nav nav-tabs" role="tablist">
<li class="active" role="presentation"><a href="#tabs-1" aria-controls="tabs-1" role="tab" data-toggle="tab">{% trans 'Relatório' %}</a></li>
<li role="presentation"><a href="#tabs-2" aria-controls="tabs-2" role="tab" data-toggle="tab">{% trans 'Arquivo CSV (Excel, Calc)' %}</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="tabs-1">
<form action="../reports/{{ query_str }}" method="post">{% csrf_token %}
<fieldset>
<legend>{% trans 'Relatório por' %}</legend>
<ul class="tabs-conteudo">
<li>
<input type="radio" name="filtro_casa" value="tudo" checked="checked"/>
<label>{% trans 'Todos' %}</label>
</li>
<li>
<input type="radio" name="filtro_casa" value="cm"/>
<label>{% trans 'Câmara Municipal' %}</label>
</li>
<li>
<input type="radio" name="filtro_casa" value="al" />
<label>{% trans 'Assembléia Legislativa' %}</label>
</li>
</ul>
</fieldset>
<fieldset>
<legend>{% trans 'Com data de aceite? (Equipada)' %}</legend>
<ul class="tabs-conteudo">
<li>
<input type="radio" name="data_aceite" value="sim" checked="checked" />
<label>{% trans 'Sim' %}</label>
</li>
<input type="radio" name="data_aceite" value="sim" checked="checked" />
<label>{% trans 'Sim' %}</label>
</li>
<li>
<input type="radio" name="data_aceite" value="nao" />
<label>{% trans 'Não' %}</label>
</li>
<input type="radio" name="data_aceite" value="nao" />
<label>{% trans 'Não' %}</label>
</li>
</ul>
</fieldset>
<ul class="botoes">
<li><input type="submit" value="Gerar Relatório"></li>
</ul>
</form>
<input type="submit" value="Gerar Relatório" type="button" class="btn btn-primary">
</form>
</div>
<div id="tabs-2">
<div role="tabpanel" class="tab-pane" id="tabs-2">
<form action="../csv/{{query_str}}" method="post">{% csrf_token %}
<fieldset><legend>{% trans 'Escolha os atributos para exportar' %}</legend>
<ul id="sortable" class="tabs-conteudo">
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="No. Processo"
<fieldset>
<legend>{% trans 'Escolha os atributos para exportar' %}</legend>
<ul id="sortable" class="tabs-conteudo">
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="No. Processo"
class="action-select" checked="checked" />
<label>{% trans 'Nº Processo' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="No. Convênio"
<label>{% trans 'Nº Processo' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="No. Convênio"
class="action-select" checked="checked" />
<label>{% trans 'Nº Convênio' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Projeto"
<label>{% trans 'Nº Convênio' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Projeto"
class="action-select" checked="checked" />
<label>{% trans 'Projeto' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Casa Legislativa"
<label>{% trans 'Projeto' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Casa Legislativa"
class="action-select" checked="checked" />
<label>{% trans 'Casa Legislativa' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Data de Adesão"
<label>{% trans 'Casa Legislativa' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Data de Adesão"
class="action-select" checked="checked" />
<label>{% trans 'Data de Adesão' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Data de Convênio"
<label>{% trans 'Data de Adesão' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Data de Convênio"
class="action-select" checked="checked" />
<label>{% trans 'Data de Convênio' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Data da Publicacao no D.O."
<label>{% trans 'Data de Convênio' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Data da Publicacao no D.O."
class="action-select" checked="checked" />
<label>{% trans 'Data da Publicação no Diário Oficial' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Data Equipada"
<label>{% trans 'Data da Publicação no Diário Oficial' %}</label>
</li>
<li>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<input type="checkbox" name="itens_csv_selected" value="Data Equipada"
class="action-select" checked="checked" />
<label>{% trans 'Data Equipada' %}</label>
</li>
</ul>
</fieldset>
<ul class="botoes">
<li><input type="submit" value="Exportar CSV" /></li>
</ul>
</form>
</div>
<label>{% trans 'Data Equipada' %}</label>
</li>
</ul>
</fieldset>
<input type="submit" value="Exportar CSV" type="button" class="btn btn-primary"/>
</form>
</div>
</div>
{% endblock %}

25
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])

Loading…
Cancel
Save