Browse Source

Fix #633

pull/907/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
5e6ab14131
  1. 20
      sapl/comissoes/views.py
  2. 69
      sapl/templates/comissoes/composicao_list.html

20
sapl/comissoes/views.py

@ -42,6 +42,26 @@ class ComposicaoCrud(MasterDetailCrud):
model_set = 'participacao_set'
public = [RP_LIST, RP_DETAIL, ]
class ListView(MasterDetailCrud.ListView):
template_name = "comissoes/composicao_list.html"
paginate_by = None
def take_composicao_pk(self):
try:
return int(self.request.GET['pk'])
except:
return 0
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['composicao_pk'] = context['composicao_list'].first(
).pk if self.take_composicao_pk(
) == 0 else self.take_composicao_pk()
context['participacao_set'] = Participacao.objects.filter(
composicao__pk=context['composicao_pk']
).order_by('parlamentar')
return context
class ComissaoCrud(Crud):
model = Comissao

69
sapl/templates/comissoes/composicao_list.html

@ -0,0 +1,69 @@
{% extends "crud/list.html" %}
{% load i18n common_tags crispy_forms_tags%}
{% block base_content %}
<div class="context-actions clearfix">
{% block actions %}
<div class="actions btn-group pull-right btn-group-lg" role="group">
{% if view.create_url %}
<a href="{{ view.create_url }}" class="btn btn-default">
{% blocktrans with verbose_name=view.verbose_name %} Adicionar {{ verbose_name }} {% endblocktrans %}
</a>
{% endif %}
{% block more_buttons %}{% endblock more_buttons %}
</div>
{% endblock actions %}
</div>
<fieldset class="form-group">
<legend>Selecione o Período</legend>
<form method="GET">
<select name="pk" class="form-control" onChange="form.submit();">
{% for c in composicao_list %}
<option value="{{c.id}}">
{{c}}
</option>
{% endfor %}
</select>
</form>
</fieldset>
<br/>
<div class="actions btn-group pull-right btn-group-lg" role="group">
<a href="{% url 'sapl.comissoes:participacao_create' composicao_pk %}" class="btn btn-default">
Adicionar Participação em Comissão
</a>
</div>
<br />
<div class="container-table">
<table class="table table-striped table-hover table-link-ordering">
<thead>
<tr>
<th>Participações em Comissão</th>
<th>Cargo</th>
<th>Titular?</th>
<th>Designação</th>
<th>Desligamento</th>
<th>Motivo</th>
<th>Observações</th>
</tr>
</thead>
<tbody>
{% for p in participacao_set %}
<tr>
<td>
<a href="{% url 'sapl.comissoes:participacao_detail' p.pk %}">{{ p.parlamentar }}</a>
</td>
<td>{{p.cargo}}</td>
<td>{{p.titular|yesno:"Sim,Não"}}</td>
<td>{{p.data_designacao}}</td>
<td>{{p.data_desligamento}}</td>
<td>{{p.motivo}}</td>
<td>{{p.observacao}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock base_content %}
Loading…
Cancel
Save