Browse Source

Lista de gerentes interlegis

pull/66/head
Sesostris Vieira 4 years ago
parent
commit
7d14171ee8
  1. 57
      sigi/apps/casas/templates/casas/gerentes_interlegis.html
  2. 143
      sigi/apps/casas/templates/casas/gerentes_interlegis_pdf.html
  3. 2
      sigi/apps/casas/urls.py
  4. 62
      sigi/apps/casas/views.py
  5. 2
      sigi/apps/home/templatetags/menu_conf.yaml

57
sigi/apps/casas/templates/casas/gerentes_interlegis.html

@ -0,0 +1,57 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_static %}
{% load static from staticfiles %}
{% block coltype %}colMS{% endblock %}
{% block content_title %}<h1>{% blocktrans %}Gerentes Interlegis{% endblocktrans %}</h1>{% endblock %}
{% block content %}
<div id="navbar-object-tools" class="nav">
<ul class="nav navbar-nav navbar-left">
<li><a href="?fmt=pdf">
<span class="glyphicon glyphicon-print"></span>
Relatório PDF
</a></li>
<li><a href="?fmt=csv&casas=yes">
<span class="glyphicon glyphicon-list-alt"></span>
CSV com casas
</a></li>
<li><a href="?fmt=csv&casas=no">
<span class="glyphicon glyphicon-list-alt"></span>
CSV sem casas
</a></li>
</ul>
</div>
<div id="content" class="colM">
{% for linha in gerentes %}
<div class="panel panel-primary">
<div class="panel-heading">
<p>{{ linha.gerente.nome_completo }} <span class="badge">{{ linha.gerente.casas_que_gerencia.count }}</span></p>
</div>
<div class="panel-body">
<ul class="nav nav-pills" role="tablist">
{% for uf in linha.ufs %}
<li role="presentation">
<a href="#tab{{ linha.gerente.id }}-{{ uf.0 }}" aria-controls="tab{{ linha.gerente.id }}-{{ uf.0 }}" role="tab" data-toggle="tab">{{ uf.1 }} <span class="badge">{{ uf.2|length }}</span></a>
</li>
{% endfor %}
</ul>
<div class="tab-content">
{% for uf in linha.ufs %}
<div role="tabpanel" class="tab-pane" id="tab{{ linha.gerente.id }}-{{ uf.0 }}">
<ul class="list-group list-inline">
{% for casa in uf.2 %}
<li class="list-group-item list-inline-item">
<a href="{% url 'admin:casas_orgao_change' casa.id %}" target="_blank">{{ casa }}</a></li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}

143
sigi/apps/casas/templates/casas/gerentes_interlegis_pdf.html

@ -0,0 +1,143 @@
{% load static from staticfiles %}
{% load i18n %}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Casa Legislativa</title>
<style type="text/css">
table {
padding: 3px;
line-height: 1em;
-fs-table-paginate: paginate;
}
thead {
display: table-header-group;
}
th {
font-weight: bold;
text-align: left;
}
th, td {
border-bottom: 1px solid #ddd;
vertical-align: top;
}
td.logo {
text-align: center;
}
td.header_text p {
margin: 0px;
font-size: 1.4em;
}
td.header_text {
width: 550px;
}
ul {
list-style-type: none;
padding-left: 15px;
}
li {
padding-left: 5px;
color: #999;
}
li.selected {
list-style-type: disc;
color: #000;
font-weight: bold;
}
p.strong {
margin-left: 25px;
line-height: 1em;
}
h1 {
font-size: 2em;
text-align: center;
}
h2 {
font-size: 1.7em;
}
h3 {
margin-top: 10px;
margin-bottom: 0px;
}
body {
font-family: "Helvetica, Arial, sans-serif";
font-size: 1.3em;
line-height: 1em;
}
div.new_page {
page-break-before: always;
}
div.same_page_ {
-pdf-keep-with-next: true;
}
.text-right {
text-align: right;
}
@page {
margin: 4cm 1cm 1cm 2cm;
font-family: "Helvetica, Arial, sans-serif";
font-size: 2em;
@frame header {
-pdf-frame-content: header;
top: 1cm;
}
@frame footer {
-pdf-frame-content: footer;
bottom: 0cm;
margin-left: 9cm;
margin-right: 9cm;
height: 1cm;
}
}
</style>
</head>
<body>
<div id="header">
<table>
<tr>
<td class="logo"><img src="{% static 'img/logo-senado.jpg' %}"/></td>
<td class="header_text">
<p><strong>{% trans 'SENADO FEDERAL' %}</strong></p>
<p><strong>{% trans 'ILB - Interlegis' %}</strong></p>
<p>{% trans 'Gerentes Interlegis' %}</p>
</td>
<td class="logo"><img src="{% static 'img/logo-interlegis.jpg' %}"/></td>
</tr>
</table>
</div>
<table>
<thead>
<tr>
<th>Gerente Interlegis</th>
<th>UF</th>
<th>Número de casas</th>
</tr>
</thead>
{% for linha in gerentes %}
{% for uf in linha.ufs %}
<tr>
{% if forloop.first %}
<td>{{ linha.gerente.nome_completo }}</td>
{% else %}
<td>&nbsp;</td>
{% endif %}
<td>{{ uf.1 }}</td>
<td class="text-right">{{ uf.2.count }}</td>
</tr>
{% endfor %}
<tr>
<td colspan="2"><strong>Total de casas atendidas por {{ linha.gerente.nome_completo }}</strong></td>
<td class="text-right"><strong>{{ linha.gerente.casas_que_gerencia.count }}</strong></td>
</tr>
{% endfor %}
</table>
<div id="footer">
{%block page_foot%}
{% trans 'Página' %} <pdf:pagenumber>
{%endblock%}
</div>
</body>
</html>

2
sigi/apps/casas/urls.py

@ -52,4 +52,6 @@ urlpatterns = patterns(
# Atualização por CSV # Atualização por CSV
url(r'^orgao/importa/$', login_required(importa_casas.as_view()), url(r'^orgao/importa/$', login_required(importa_casas.as_view()),
name='importar-casas'), name='importar-casas'),
url(r'^gerentes/$', 'gerentes_interlegis',
name='gerentes_interlegis'),
) )

62
sigi/apps/casas/views.py

@ -1035,3 +1035,65 @@ def painel_relacionamento(request):
return render(request, 'casas/resumo_carteira_snippet.html', context) return render(request, 'casas/resumo_carteira_snippet.html', context)
return render(request, 'casas/painel.html', context) return render(request, 'casas/painel.html', context)
@login_required
def gerentes_interlegis(request):
formato = request.GET.get('fmt', 'html')
inclui_casas = (request.GET.get('casas', 'no') == 'yes')
gerentes = Servidor.objects.exclude(
casas_que_gerencia=None).select_related('casas_que_gerencia')
dados = []
for gerente in gerentes:
row = {'gerente': gerente, 'ufs': []}
for uf in (gerente.casas_que_gerencia.distinct('municipio__uf__sigla')
.order_by('municipio__uf__sigla')
.values_list('municipio__uf__sigla', 'municipio__uf__nome')
):
row['ufs'].append((
uf[0],
uf[1],
gerente.casas_que_gerencia.filter(municipio__uf__sigla=uf[0])
))
dados.append(row)
if formato == 'pdf':
return render_to_pdf(
'casas/gerentes_interlegis_pdf.html',
{'gerentes': dados}
)
elif formato == 'csv':
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = ('attachment; '
'filename="gerentes_interlegis.csv"')
fieldnames = ['gerente', 'total_casas', 'uf', 'total_casas_uf']
if inclui_casas:
fieldnames.append('casa_legislativa')
writer = csv.DictWriter(response, fieldnames=fieldnames)
writer.writeheader()
for linha in dados:
rec = {
'gerente': linha['gerente'].nome_completo.encode('utf8'),
'total_casas': linha['gerente'].casas_que_gerencia.count()
}
for uf in linha['ufs']:
rec['uf'] = uf[1].encode('utf8')
rec['total_casas_uf'] = uf[2].count()
if inclui_casas:
for casa in uf[2]:
rec['casa_legislativa'] = casa.nome.encode('utf8')
writer.writerow(rec)
rec['gerente'] = ''
rec['total_casas'] = ''
rec['uf'] = ''
rec['total_casas_uf'] = ''
else:
writer.writerow(rec)
rec['gerente'] = ''
rec['total_casas'] = ''
return response
return render(
request,
'casas/gerentes_interlegis.html',
{'gerentes': dados}
)

2
sigi/apps/home/templatetags/menu_conf.yaml

@ -23,6 +23,8 @@ main_menu:
url: casas/carteira url: casas/carteira
- title: Organizar relacionamentos - title: Organizar relacionamentos
url: casas/portfolio/ url: casas/portfolio/
- title: Lista de gerentes
url: casas/gerentes/
- title: Convênios - title: Convênios
children: children:
- title: Convênios - title: Convênios

Loading…
Cancel
Save