From 7b9ab90f44b35933308c4037ed6f0c7847a04ec6 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Tue, 8 Aug 2017 11:04:46 -0300 Subject: [PATCH 1/7] =?UTF-8?q?Ajusta=20test=5Fmateria.py=20e=20erro=20apo?= =?UTF-8?q?ntados=20p=C3=B3s=20ajustes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/forms.py | 9 +++++--- .../migrations/0011_auto_20170808_1034.py | 19 ++++++++++++++++ sapl/materia/tests/test_materia.py | 22 +++++++++---------- 3 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 sapl/materia/migrations/0011_auto_20170808_1034.py diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 11e2d62b7..1c6ad78b1 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -697,7 +697,7 @@ class AutoriaForm(ModelForm): empty_label=_('Selecione'),) data_relativa = forms.DateField( - widget=forms.HiddenInput()) + widget=forms.HiddenInput(), required=False) def __init__(self, *args, **kwargs): super(AutoriaForm, self).__init__(*args, **kwargs) @@ -721,12 +721,15 @@ class AutoriaForm(ModelForm): def clean(self): cd = super(AutoriaForm, self).clean() + if self.errors: + return self.errors + autorias = Autoria.objects.filter( materia=self.instance.materia, autor=cd['autor']) pk = self.instance.pk - if ((not pk and autorias.exists()) - or (pk and autorias.exclude(pk=pk).exists())): + if ((not pk and autorias.exists()) or + (pk and autorias.exclude(pk=pk).exists())): raise ValidationError(_('Esse Autor já foi cadastrado.')) return cd diff --git a/sapl/materia/migrations/0011_auto_20170808_1034.py b/sapl/materia/migrations/0011_auto_20170808_1034.py new file mode 100644 index 000000000..209a87c70 --- /dev/null +++ b/sapl/materia/migrations/0011_auto_20170808_1034.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.13 on 2017-08-08 10:34 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('materia', '0010_auto_20170808_0850'), + ] + + operations = [ + migrations.AlterModelOptions( + name='autoria', + options={'ordering': ('-primeiro_autor', 'autor__nome'), 'verbose_name': 'Autoria', 'verbose_name_plural': 'Autorias'}, + ), + ] diff --git a/sapl/materia/tests/test_materia.py b/sapl/materia/tests/test_materia.py index 20f3a12fa..fc160b952 100644 --- a/sapl/materia/tests/test_materia.py +++ b/sapl/materia/tests/test_materia.py @@ -1,9 +1,9 @@ -import pytest from django.contrib.auth import get_user_model from django.contrib.contenttypes.models import ContentType from django.core.files.uploadedfile import SimpleUploadedFile from django.core.urlresolvers import reverse from model_mommy import mommy +import pytest from sapl.base.models import Autor, TipoAutor from sapl.comissoes.models import Comissao, TipoComissao @@ -133,14 +133,15 @@ def test_autoria_submit(admin_client): nome='Autor Teste') # Testa POST - response = admin_client.post(reverse('sapl.materia:autoria_create', - kwargs={'pk': materia_principal.pk}), - {'autor': autor.pk, - 'primeiro_autor': True, - 'materia_id': materia_principal.pk, - 'partido': '', - 'salvar': 'salvar'}, - follow=True) + response = admin_client.post( + reverse('sapl.materia:autoria_create', + kwargs={'pk': materia_principal.pk}), + {'autor': autor.pk, + 'primeiro_autor': True, + 'materia_id': materia_principal.pk, + 'data_relativa': '', + 'salvar': 'salvar'}, + follow=True) assert response.status_code == 200 # Verifica se o autor foi realmente criado @@ -323,8 +324,7 @@ def test_form_errors_autoria(admin_client): response = admin_client.post(reverse('sapl.materia:autoria_create', kwargs={'pk': materia_principal.pk}), {'materia_id': materia_principal.pk, - 'partido': '', - 'autor': '', + 'autor_id': '', 'salvar': 'salvar'}, follow=True) From 950e122beaab0e7f752f924f37b11c84279c2d78 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Tue, 8 Aug 2017 11:16:58 -0300 Subject: [PATCH 2/7] =?UTF-8?q?Retira=20campos=20desnecess=C3=A1rios=20em?= =?UTF-8?q?=20teste=20de=20autoria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/tests/test_materia.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sapl/materia/tests/test_materia.py b/sapl/materia/tests/test_materia.py index fc160b952..5366959d2 100644 --- a/sapl/materia/tests/test_materia.py +++ b/sapl/materia/tests/test_materia.py @@ -138,9 +138,7 @@ def test_autoria_submit(admin_client): kwargs={'pk': materia_principal.pk}), {'autor': autor.pk, 'primeiro_autor': True, - 'materia_id': materia_principal.pk, - 'data_relativa': '', - 'salvar': 'salvar'}, + 'materia_id': materia_principal.pk, }, follow=True) assert response.status_code == 200 @@ -324,8 +322,7 @@ def test_form_errors_autoria(admin_client): response = admin_client.post(reverse('sapl.materia:autoria_create', kwargs={'pk': materia_principal.pk}), {'materia_id': materia_principal.pk, - 'autor_id': '', - 'salvar': 'salvar'}, + 'autor_id': '', }, follow=True) assert (response.context_data['form'].errors['autor'] == From 89e82a60de7423f8d4ed27e74f8b4e0b26562b54 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Tue, 8 Aug 2017 12:44:01 -0300 Subject: [PATCH 3/7] =?UTF-8?q?Adiciona=20cria=C3=A7=C3=A3o=20de=20tipo=5F?= =?UTF-8?q?situacao=5Fmilitar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luciano Almeida --- sapl/legacy/scripts/fix_tables.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sapl/legacy/scripts/fix_tables.sql b/sapl/legacy/scripts/fix_tables.sql index 3b0d55c7b..1f8cdb63b 100644 --- a/sapl/legacy/scripts/fix_tables.sql +++ b/sapl/legacy/scripts/fix_tables.sql @@ -5,6 +5,7 @@ DROP PROCEDURE IF EXISTS verifica_campos_proposicao; DROP PROCEDURE IF EXISTS verifica_campos_tipo_materia_legislativa; DROP PROCEDURE IF EXISTS verifica_campos_sessao_plenaria_presenca; DROP PROCEDURE IF EXISTS cria_lexml_registro_provedor_e_publicador; +DROP PROCEDURE IF EXISTS cria_tipo_situacao_militar; DROP PROCEDURE IF EXISTS muda_vinculo_norma_juridica_ind_excluido; -- Procedure para criar campo num_proposicao em proposicao CREATE PROCEDURE verifica_campos_proposicao() BEGIN IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='proposicao' AND column_name='num_proposicao') THEN UPDATE proposicao SET dat_envio = '1800-01-01' WHERE CAST(dat_envio AS CHAR(20)) = '0000-00-00 00:00:00'; ALTER TABLE proposicao ADD COLUMN num_proposicao INT(11) NULL after txt_justif_devolucao; END IF; END; @@ -14,6 +15,8 @@ CREATE PROCEDURE verifica_campos_tipo_materia_legislativa() BEGIN IF NOT EXISTS CREATE PROCEDURE verifica_campos_sessao_plenaria_presenca() BEGIN IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='sessao_plenaria_presenca' AND column_name='cod_presenca_sessao') THEN ALTER TABLE sessao_plenaria_presenca DROP PRIMARY KEY, ADD cod_presenca_sessao INT AUTO_INCREMENT PRIMARY KEY FIRST; END IF; IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='sessao_plenaria_presenca' AND column_name='dat_sessao') THEN ALTER TABLE sessao_plenaria_presenca ADD COLUMN dat_sessao DATE NULL after cod_parlamentar; END IF; END; -- Procedure para criar tabela lexml_registro_provedor e lexml_registro_publicador CREATE PROCEDURE cria_lexml_registro_provedor_e_publicador() BEGIN IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='lexml_registro_publicador') THEN CREATE TABLE lexml_registro_publicador (cod_publicador INT AUTO_INCREMENT NOT NULL, id_publicador INT, nom_publicador VARCHAR(255), adm_email VARCHAR(50), sigla VARCHAR(255), nom_responsavel VARCHAR(255), tipo VARCHAR(50), id_responsavel INT, PRIMARY KEY (cod_publicador)); END IF; IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='lexml_registro_provedor') THEN CREATE TABLE lexml_registro_provedor (cod_provedor INT AUTO_INCREMENT NOT NULL, id_provedor INT, nom_provedor VARCHAR(255), sgl_provedor VARCHAR(15), adm_email VARCHAR(50), nom_responsavel VARCHAR(255), tipo VARCHAR(50), id_responsavel INT, xml_provedor LONGTEXT, PRIMARY KEY (cod_provedor)); END IF; END; +-- Procedure para criar tabela tipo_situacao_militar +CREATE PROCEDURE cria_tipo_situacao_militar() BEGIN IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='tipo_situacao_militar') THEN CREATE TABLE tipo_situacao_militar (tip_situacao_militar INT AUTO_INCREMENT NOT NULL, des_tipo_situacao VARCHAR(50), ind_excluido INT, PRIMARY KEY (tip_situacao_militar)); END IF; END; -- Procedure para mudar valor do campo ind_excluido da tabela vinculo_norma_juridica de 0 para string vazia '' CREATE PROCEDURE muda_vinculo_norma_juridica_ind_excluido() BEGIN UPDATE vinculo_norma_juridica SET ind_excluido = '' WHERE trim(ind_excluido) = '0'; END; -- Executa as procedures criadas acima @@ -21,4 +24,5 @@ CALL verifica_campos_proposicao; CALL verifica_campos_tipo_materia_legislativa; CALL verifica_campos_sessao_plenaria_presenca; CALL cria_lexml_registro_provedor_e_publicador; +CALL cria_tipo_situacao_militar; CALL muda_vinculo_norma_juridica_ind_excluido; From 96d386e1628419db1bdedd1b9e59423e376ed472 Mon Sep 17 00:00:00 2001 From: Eliseu Egewarth Date: Tue, 8 Aug 2017 14:03:42 -0300 Subject: [PATCH 4/7] 1357 implementar visao reduzida de parlamentares (#1364) * Fix #1357 Signed-off-by: Eliseu Egewarth * Atualiza views para receber o query_string 'iframe' Signed-off-by: Eliseu Egewarth --- sapl/redireciona_urls/views.py | 66 +++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/sapl/redireciona_urls/views.py b/sapl/redireciona_urls/views.py index 8e9d5afbe..42b0fcadd 100644 --- a/sapl/redireciona_urls/views.py +++ b/sapl/redireciona_urls/views.py @@ -50,6 +50,20 @@ relatorio_materia_por_ano_autor_tipo = ( historico_tramitacoes = (app_relatorios + ':historico_tramitacoes') + +def has_iframe(url, request): + + iframe = request.GET.get( + 'iframe', + EMPTY_STRING) + if iframe: + iframe_qs= ("iframe=" + iframe) + url += ("&" if "?" in url else "?") + url += iframe_qs + + return url + + class RedirecionaSAPLIndex(RedirectView): permanent = True @@ -59,6 +73,9 @@ class RedirecionaSAPLIndex(RedirectView): url = reverse(url_pattern) except NoReverseMatch: raise UnknownUrlNameError(url_pattern) + + url = has_iframe(url, self.request) + return url @@ -90,6 +107,8 @@ class RedirecionaParlamentar(RedirectView): args = '?pk=' + numero_legislatura url = "%s%s" % (url, args) + url = has_iframe(url, self.request) + return url @@ -112,6 +131,9 @@ class RedirecionaComissao(RedirectView): url = reverse(comissao_list) except NoReverseMatch: raise UnknownUrlNameError(comissao_list) + + url = has_iframe(url, self.request) + return url @@ -151,6 +173,8 @@ class RedirecionaPautaSessao(RedirectView): args += "&tipo=&salvar=Pesquisar" url = "%s%s" % (url, args) + url = has_iframe(url, self.request) + return url @@ -198,6 +222,8 @@ class RedirecionaSessaoPlenaria(RedirectView): args += "&tipo=%s&salvar=Pesquisar" % (tipo_sessao) url = "%s%s" % (url, args) + url = has_iframe(url, self.request) + return url @@ -210,6 +236,9 @@ class RedirecionaRelatoriosList(RedirectView): url = reverse(relatorios_list) except NoReverseMatch: raise UnknownUrlNameError(relatorios_list) + + url = has_iframe(url, self.request) + return url @@ -253,6 +282,8 @@ class RedirecionaRelatoriosMateriasEmTramitacaoList(RedirectView): args += "&salvar=%s" % (salvar) url = "%s%s" % (url, args) + url = has_iframe(url, self.request) + return url @@ -260,13 +291,18 @@ class RedirecionaMateriaLegislativaDetail(RedirectView): permanent = True def get_redirect_url(self): + url = EMPTY_STRING pk = self.request.GET.get('cod_materia', EMPTY_STRING) if pk: kwargs = {'pk': pk} - return reverse(materialegislativa_detail, kwargs=kwargs) + url = reverse(materialegislativa_detail, kwargs=kwargs) else: - return reverse(materialegislativa_list) + url = reverse(materialegislativa_list) + + url = has_iframe(url, self.request) + + return url class RedirecionaMateriaLegislativaList(RedirectView): @@ -339,6 +375,8 @@ class RedirecionaMateriaLegislativaList(RedirectView): url = "%s%s" % (url, args) + url = has_iframe(url, self.request) + return url @@ -346,11 +384,14 @@ class RedirecionaMesaDiretoraView(RedirectView): permanent = True def get_redirect_url(self): + url = EMPTY_STRING try: url = reverse(parlamentar_mesa_diretora) except NoReverseMatch: raise UnknownUrlNameError(parlamentar_mesa_diretora) + url = has_iframe(url, self.request) + return url @@ -358,13 +399,18 @@ class RedirecionaNormasJuridicasDetail(RedirectView): permanent = True def get_redirect_url(self): + url = EMPTY_STRING pk_norma = self.request.GET.get('cod_norma', EMPTY_STRING) if pk_norma: kwargs = {'pk': pk_norma} - return reverse(norma_juridica_detail, kwargs=kwargs) + url = reverse(norma_juridica_detail, kwargs=kwargs) else: - return reverse(norma_juridica_pesquisa) + url = reverse(norma_juridica_pesquisa) + + url = has_iframe(url, self.request) + + return url class RedirecionaNormasJuridicasList(RedirectView): @@ -420,6 +466,8 @@ class RedirecionaNormasJuridicasList(RedirectView): url = "%s%s" % (url, args) + url = has_iframe(url, self.request) + return url @@ -475,6 +523,8 @@ class RedirecionaHistoricoTramitacoesList(RedirectView): url = "%s%s" % (url, args) + url = has_iframe(url, self.request) + return url @@ -507,6 +557,8 @@ class RedirecionaAtasList(RedirectView): url = "%s%s" % (url, args) + url = has_iframe(url, self.request) + return url @@ -539,6 +591,8 @@ class RedirecionaPresencaParlamentares(RedirectView): url = "%s%s" % (url, args) + url = has_iframe(url, self.request) + return url @@ -553,6 +607,8 @@ class RedirecionaMateriasPorAutor(RedirectView): except NoReverseMatch: raise UnknownUrlNameError(relatorio_materia_por_autor) + url = has_iframe(url, self.request) + return url @@ -574,4 +630,6 @@ class RedirecionaMateriasPorAnoAutorTipo(RedirectView): args += "&salvar=%s" % ('Pesquisar') url = "%s%s" % (url, args) + url = has_iframe(url, self.request) + return url From ed1630cb25005e5bc2d2b4f23973c308e19980f7 Mon Sep 17 00:00:00 2001 From: Eliseu Egewarth Date: Tue, 8 Aug 2017 14:03:56 -0300 Subject: [PATCH 5/7] Fix #1305 (#1361) Signed-off-by: Eliseu Egewarth --- sapl/sessao/views.py | 2 +- sapl/templates/sessao/pauta_sessao_detail.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index 61cadbf71..96184dd59 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -2268,7 +2268,7 @@ class PautaSessaoDetailView(DetailView): tipo = TipoExpediente.objects.get( id=e.tipo_id) conteudo = sub( - ' ', ' ', strip_tags(e.conteudo)) + ' ', ' ', strip_tags(e.conteudo.replace('
', '\n'))) ex = {'tipo': tipo, 'conteudo': conteudo} expedientes.append(ex) diff --git a/sapl/templates/sessao/pauta_sessao_detail.html b/sapl/templates/sessao/pauta_sessao_detail.html index a16f86802..82cbb686a 100644 --- a/sapl/templates/sessao/pauta_sessao_detail.html +++ b/sapl/templates/sessao/pauta_sessao_detail.html @@ -25,7 +25,7 @@ {{e.tipo}}:
-

{{e.conteudo|safe}}

+

{{e.conteudo|safe|linebreaks}}

{% endfor %} From 1955c527f693c93f3899ccf615807ad0e54cda03 Mon Sep 17 00:00:00 2001 From: Eliseu Egewarth Date: Tue, 8 Aug 2017 14:04:12 -0300 Subject: [PATCH 6/7] Fix #1342 (#1360) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix #1342 Signed-off-by: Eliseu Egewarth * Corrige erro de lógica Signed-off-by: Eliseu Egewarth --- sapl/protocoloadm/forms.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index c8880960c..a3b71e998 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -12,7 +12,7 @@ from django.utils.translation import ugettext_lazy as _ from sapl.base.models import Autor from sapl.crispy_layout_mixin import form_actions, to_row -from sapl.materia.models import TipoMateriaLegislativa, UnidadeTramitacao +from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa, UnidadeTramitacao from sapl.utils import (RANGE_ANOS, AnoNumeroOrderingFilter, RangeWidgetOverride, autor_label, autor_modal) @@ -233,7 +233,18 @@ class AnularProcoloAdmForm(ModelForm): except ObjectDoesNotExist: raise forms.ValidationError( _("Protocolo %s/%s não existe" % (numero, ano))) - + exists = False + if protocolo.tipo_materia: + exists = MateriaLegislativa.objects.filter( + numero_protocolo=protocolo.numero, ano=protocolo.ano).exists() + elif protocolo.tipo_documento: + exists = protocolo.documentoadministrativo_set.all( + ).order_by('-ano', '-numero').exists() + + if exists: + raise forms.ValidationError( + _("Protocolo %s/%s não pode ser removido pois existem" + "documentos vinculados a ele." % (numero, ano))) class Meta: model = Protocolo fields = ['numero', From d351e7c7bb5aa565fc4352f649854e10253f2a9e Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Tue, 8 Aug 2017 19:01:45 -0300 Subject: [PATCH 7/7] =?UTF-8?q?Conserta=20a=20query=20de=20Relat=C3=B3rio?= =?UTF-8?q?=20sobre=20Presen=C3=A7a=20em=20Sess=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sapl/base/views.py b/sapl/base/views.py index 4c86ff515..718774d46 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -21,7 +21,7 @@ from sapl.base.models import Autor, TipoAutor from sapl.crud.base import CrudAux from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.parlamentares.models import Parlamentar -from sapl.sessao.models import OrdemDia, SessaoPlenaria +from sapl.sessao.models import PresencaOrdemDia, SessaoPlenaria from sapl.utils import sapl_logger from .forms import (CasaLegislativaForm, ConfiguracoesAppForm, @@ -253,9 +253,9 @@ class RelatorioPresencaSessaoView(FilterView): sessao_count=0, ordemdia_count=0) - total_ordemdia = OrdemDia.objects.order_by( - 'sessao_plenaria').filter(**param0).distinct( - 'sessao_plenaria').count() + total_ordemdia = PresencaOrdemDia.objects.filter( + **param0).distinct('sessao_plenaria__id').order_by( + 'sessao_plenaria__id').count() self.calcular_porcentagem_presenca( pls,