From 01b9b6e0424c27bc602927a81599ceb55124fe60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Fri, 13 Mar 2020 13:55:06 -0300 Subject: [PATCH] =?UTF-8?q?Fix=20#3117=20-=20Filtra=20as=20coliga=C3=A7?= =?UTF-8?q?=C3=B5es=20no=20cadastro=20de=20Mandato=20(#3118)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Criar novo endpoint * Implementa retorno de coligações por legislatura * Filtra coligacões por legislatura * Refatoração * Update sapl/parlamentares/views.py Co-Authored-By: Edward <9326037+edwardoliveira@users.noreply.github.com> * Update sapl/templates/parlamentares/mandato_form.html Co-Authored-By: Edward <9326037+edwardoliveira@users.noreply.github.com> * Refatoração Co-authored-by: Edward <9326037+edwardoliveira@users.noreply.github.com> --- sapl/parlamentares/urls.py | 4 ++ sapl/parlamentares/views.py | 13 +++++- .../templates/parlamentares/mandato_form.html | 41 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 sapl/templates/parlamentares/mandato_form.html diff --git a/sapl/parlamentares/urls.py b/sapl/parlamentares/urls.py index 6e175bafe..60fbf3232 100644 --- a/sapl/parlamentares/urls.py +++ b/sapl/parlamentares/urls.py @@ -1,6 +1,7 @@ from django.conf.urls import include, url from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud, + coligacao_legislatura, ComposicaoColigacaoCrud, DependenteCrud, FiliacaoCrud, FrenteCrud, FrenteList, LegislaturaCrud, MandatoCrud, @@ -45,6 +46,9 @@ urlpatterns = [ url(r'^parlamentar/vincular-parlamentar/$', VincularParlamentarView.as_view(), name='vincular_parlamentar'), + url(r'^parlamentar/coligacao-legislatura/', + coligacao_legislatura, name="coligacao_legislatura"), + url(r'^sistema/coligacao/', include(ColigacaoCrud.get_urls() + ComposicaoColigacaoCrud.get_urls())), diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index b176f056f..ebf116330 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -312,6 +312,17 @@ class ColigacaoCrud(CrudAux): return context +def coligacao_legislatura(request): + try: + coligacoes = Coligacao.objects.filter(legislatura=request.GET['legislatura']).order_by('nome') + except: + coligacoes = [] + + lista_coligacoes = [(coligacao.id, str(coligacao)) for coligacao in coligacoes] + + return JsonResponse({'coligacoes': lista_coligacoes}) + + def json_date_convert(date): """ :param date: recebe a data de uma chamada ajax no formato de @@ -1124,4 +1135,4 @@ def get_sessoes_legislatura(request): for s in SessaoLegislativa.objects.filter(legislatura_id=legislatura_id): json_response['sessoes_legislativas'].append( (s.id, str(s)) ) - return JsonResponse(json_response) \ No newline at end of file + return JsonResponse(json_response) diff --git a/sapl/templates/parlamentares/mandato_form.html b/sapl/templates/parlamentares/mandato_form.html new file mode 100644 index 000000000..fc658a7e8 --- /dev/null +++ b/sapl/templates/parlamentares/mandato_form.html @@ -0,0 +1,41 @@ +{% extends "crud/form.html" %} +{% load i18n %} +{% load crispy_forms_tags %} +{% load common_tags %} + +{% block extra_js %} + +{% endblock %}