Browse Source

Merge pull request #136 from interlegis/branch_nova

Branch nova
new_sigi
Davi-Galati 3 years ago
committed by GitHub
parent
commit
c59e127516
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      sigi/apps/convenios/templates/convenios/change_list.html
  2. 20
      sigi/apps/eventos/views.py

16
sigi/apps/convenios/templates/convenios/change_list.html

@ -14,32 +14,34 @@
<a class="navbar-brand" href="#">Filtro de datas</a> <a class="navbar-brand" href="#">Filtro de datas</a>
<p class="navbar-text">Use AAAA, AAAA-MM ou AAAA-MM-DD</p> <p class="navbar-text">Use AAAA, AAAA-MM ou AAAA-MM-DD</p>
</div> </div>
<br>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<form class="navbar-form navbar-left" role="extra-search" id="changelist-extrasearch" action="" method="get"> <form class="navbar-form navbar-left" role="extra-search" id="changelist-extrasearch" action="" method="get">
<div class="form-group"> <div class="form-group">
<label for="data_retorno_assinatura__gte">{% trans 'Conveniadas a partir de' %}:</label> <label for="data_retorno_assinatura__gte">{% trans 'Vigência a partir de' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_retorno_assinatura__gte" value="" id="data_retorno_assinatura__gte"> <input type="text" class="form-control search-query" size="10" name="data_retorno_assinatura__gte" value="" id="data_retorno_assinatura__gte">
<label for="data_retorno_assinatura__lte">{% trans 'até' %}:</label> <label for="data_retorno_assinatura__lte">{% trans 'até' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_retorno_assinatura__lte" value="" id="data_retorno_assinatura__lte"> <input type="text" class="form-control search-query" size="10" name="data_retorno_assinatura__lte" value="" id="data_retorno_assinatura__lte">
</div> </div>
<div class="form-group">
<label for="data_sigad__gte">{% trans 'SIGAD a partir de' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_sigad__gte" value="" id="data_sigad__gte">
<label for="data_sigad__lte">{% trans 'até' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_sigad__lte" value="" id="data_sigad__lte">
</div>
<div class="form-group"> <div class="form-group">
<label for="data_sigi__gte">{% trans 'SIGI a partir de' %}:</label> <label for="data_sigi__gte">{% trans 'SIGI a partir de' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_sigi__gte" value="" id="data_sigi__gte"> <input type="text" class="form-control search-query" size="10" name="data_sigi__gte" value="" id="data_sigi__gte">
<label for="data_sigi__lte">{% trans 'até' %}:</label> <label for="data_sigi__lte">{% trans 'até' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_sigi__lte" value="" id="data_sigi__lte"> <input type="text" class="form-control search-query" size="10" name="data_sigi__lte" value="" id="data_sigi__lte">
</div> </div>
<br>
<div class="form-group"> <div class="form-group">
<label for="data_solicitacao__gte">{% trans 'E-mail a partir de' %}:</label> <label for="data_solicitacao__gte">{% trans 'E-mail a partir de' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_solicitacao__gte" value="" id="data_solicitacao__gte"> <input type="text" class="form-control search-query" size="10" name="data_solicitacao__gte" value="" id="data_solicitacao__gte">
<label for="data_solicitacao__lte">{% trans 'até' %}:</label> <label for="data_solicitacao__lte">{% trans 'até' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_solicitacao__lte" value="" id="data_solicitacao__lte"> <input type="text" class="form-control search-query" size="10" name="data_solicitacao__lte" value="" id="data_solicitacao__lte">
</div> </div>
<div class="form-group">
<label for="data_sigad__gte">{% trans 'SIGAD a partir de' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_sigad__gte" value="" id="data_sigad__gte">
<label for="data_sigad__lte">{% trans 'até' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_sigad__lte" value="" id="data_sigad__lte">
</div>
<button type="submit" class="btn btn-default navbar-btn "> <button type="submit" class="btn btn-default navbar-btn ">
<span class="glyphicon glyphicon-search"></span> <span class="glyphicon glyphicon-search"></span>
</button> </button>

20
sigi/apps/eventos/views.py

@ -300,6 +300,13 @@ def deleta_itens_carrinho(request):
@login_required @login_required
def export_csv(request): def export_csv(request):
def rm_rows(lista,reg):
for a in lista:
if a in lista:
reg.pop(a,None)
else:
pass
def serialize(r, field): def serialize(r, field):
value = (getattr(r, 'get_{0}_display'.format(field.name), None) or value = (getattr(r, 'get_{0}_display'.format(field.name), None) or
getattr(r, field.name, "")) getattr(r, field.name, ""))
@ -332,7 +339,16 @@ def export_csv(request):
response = HttpResponse(content_type='text/csv') response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename=eventos.csv' response['Content-Disposition'] = 'attachment; filename=eventos.csv'
rm_list = ['Descrição do evento', 'Local do evento', 'Público alvo', 'Motivo do cancelamento', 'Observações_1',
'Observações_2', 'Observações_3', 'Observações_4', 'Observações_5', 'Observações_6', 'Observações_7', 'Observações_8']
for a in rm_list:
if a in head:
head.remove(a)
else:
pass
writer = csv.DictWriter(response, fieldnames=head) writer = csv.DictWriter(response, fieldnames=head)
writer.writeheader() writer.writeheader()
@ -366,8 +382,12 @@ def export_csv(request):
for f in Convite._meta.fields for f in Convite._meta.fields
if f.name not in ('id', 'evento')} if f.name not in ('id', 'evento')}
) )
rm_rows(rm_list,reg)
writer.writerow(reg) writer.writerow(reg)
if evento.convite_set.count() == 0: if evento.convite_set.count() == 0:
rm_rows(rm_list,reg)
writer.writerow(reg) writer.writerow(reg)
return response return response

Loading…
Cancel
Save