From 53c632a54ade825803d28f1dfae82850cf7ce00f Mon Sep 17 00:00:00 2001 From: Cesar Carvalho Date: Fri, 31 May 2019 11:52:08 -0300 Subject: [PATCH] Esconde ou mostra tema da sessao de acordo com o tipo da sessao --- sapl/sessao/urls.py | 6 +++++- sapl/sessao/views.py | 20 ++++++++++++++----- .../templates/sessao/sessaoplenaria_form.html | 17 ++++++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/sapl/sessao/urls.py b/sapl/sessao/urls.py index c570dfde8..99c6ae81b 100644 --- a/sapl/sessao/urls.py +++ b/sapl/sessao/urls.py @@ -33,7 +33,8 @@ from sapl.sessao.views import (AdicionarVariasMateriasExpediente, renumerar_materias_expediente, sessao_legislativa_legislatura_ajax, VotacaoEmBlocoOrdemDia, VotacaoEmBlocoExpediente, - VotacaoEmBlocoSimbolicaView, VotacaoEmBlocoNominalView) + VotacaoEmBlocoSimbolicaView, VotacaoEmBlocoNominalView, + recuperar_nome_tipo_sessao) from .apps import AppConfig @@ -68,6 +69,9 @@ urlpatterns = [ recuperar_numero_sessao_view, name='recuperar_numero_sessao_view' ), + url(r'^sessao/recuperar-nome-tipo-sessao/', + recuperar_nome_tipo_sessao, + name='recuperar_nome_tipo_sessao'), url(r'^sessao/sessao-legislativa-legislatura-ajax/', sessao_legislativa_legislatura_ajax, name='sessao_legislativa_legislatura_ajax_view'), diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index 7d5b2a6b5..d6cb25b26 100755 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -842,6 +842,16 @@ def sessao_legislativa_legislatura_ajax(request): return JsonResponse({'sessao_legislativa': lista_sessoes}) +def recuperar_nome_tipo_sessao(request): + try: + tipo = TipoSessaoPlenaria.objects.get(pk=request.GET['tipo']) + tipo_nome = tipo.nome + except ObjectDoesNotExist: + tipo_nome = '' + + return JsonResponse({'nome_tipo': tipo_nome}) + + class SessaoCrud(Crud): model = SessaoPlenaria help_topic = 'sessao_legislativa' @@ -897,11 +907,11 @@ class SessaoCrud(Crud): @property def layout_key(self): - sessao = self.object - tipo_sessao = sessao.tipo - if tipo_sessao.nome == "Solene": - return 'SessaoSolene' - return 'SessaoPlenaria' + # sessao = self.object + # tipo_sessao = sessao.tipo + # if tipo_sessao.nome == "Solene": + # return 'SessaoSolene' + return 'SessaoSolene' @property def cancel_url(self): diff --git a/sapl/templates/sessao/sessaoplenaria_form.html b/sapl/templates/sessao/sessaoplenaria_form.html index aa18e0105..f4b339107 100644 --- a/sapl/templates/sessao/sessaoplenaria_form.html +++ b/sapl/templates/sessao/sessaoplenaria_form.html @@ -16,6 +16,8 @@ var legislatura = $("#id_legislatura").val() var data_ini = $("#id_data_inicio").val() + $("#div_id_tema_solene").hide(); + if (tipo) { $.get("{% url 'sapl.sessao:recuperar_numero_sessao_view' %}", { @@ -27,10 +29,23 @@ $("#id_numero").val(data.numero); } ); + + $.get("{% url 'sapl.sessao:recuperar_nome_tipo_sessao' %}", + { + tipo: tipo, + sessao_legislativa:sessao + }, + function(data, status) { + if(data.nome_tipo == "Solene"){ + $("#div_id_tema_solene").show(); + } + } + ); } else{ $("#id_numero").val(''); } + } $("#id_tipo").click(recuperar_numero_sessao); $("#id_sessao_legislativa").click(recuperar_numero_sessao); @@ -64,6 +79,8 @@ $("#id_legislatura").ready(altera_legislatura); $("#id_legislatura").change(altera_legislatura); + + $("#div_id_tema_solene").ready(recuperar_numero_sessao); });