From 28b13a43719d8ff39570f7f442a0cfadf6218d14 Mon Sep 17 00:00:00 2001
From: Cesar Augusto de Carvalho
Date: Mon, 17 Jun 2019 14:55:37 -0300
Subject: [PATCH] =?UTF-8?q?Fix=20#2843:=20Permite=20apagar=20TipoExpedient?=
=?UTF-8?q?e=20se=20s=C3=B3=20for=20referenciado=20por=20conte=C3=BAdos=20?=
=?UTF-8?q?vazios=20(#2844)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* HOT-FIX: Permite apagar TipoExpediente se só for referenciado por conteúdos vazios
* Retira Tipos vazios do resumo e extrato
---
.../templates/pdf_sessao_plenaria_gerar.py | 15 ++++++++-------
sapl/sessao/views.py | 18 +++++++++++++++++-
.../sessao/blocos_ata/expedientes.html | 10 ++++------
.../sessao/blocos_resumo/expedientes.html | 18 ++++++++++--------
4 files changed, 39 insertions(+), 22 deletions(-)
diff --git a/sapl/relatorios/templates/pdf_sessao_plenaria_gerar.py b/sapl/relatorios/templates/pdf_sessao_plenaria_gerar.py
index 4b1d62719..805731a70 100644
--- a/sapl/relatorios/templates/pdf_sessao_plenaria_gerar.py
+++ b/sapl/relatorios/templates/pdf_sessao_plenaria_gerar.py
@@ -203,13 +203,14 @@ def expedientes(lst_expedientes):
tmp += '\t\t\t \n'
tmp += '\t\t\n'
for expediente in lst_expedientes:
- tmp += '\t\t' + '
' + \
- expediente['nom_expediente'] + ': \n' + \
- '' + \
- expediente['txt_expediente'] + '\n'
- tmp += '\t\t\n'
- tmp += '\t\t\t \n'
- tmp += '\t\t\n'
+ if expediente['txt_expediente']:
+ tmp += '\t\t' + '
' + \
+ expediente['nom_expediente'] + ': \n' + \
+ '' + \
+ expediente['txt_expediente'] + '\n'
+ tmp += '\t\t\n'
+ tmp += '\t\t\t \n'
+ tmp += '\t\t\n'
return tmp
diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py
index d5794f421..4f9b144f6 100755
--- a/sapl/sessao/views.py
+++ b/sapl/sessao/views.py
@@ -53,7 +53,6 @@ from .models import (Bancada, CargoBancada, CargoMesa,
TipoSessaoCrud = CrudAux.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria')
-TipoExpedienteCrud = CrudAux.build(TipoExpediente, 'tipo_expediente')
TipoJustificativaCrud = CrudAux.build(TipoJustificativa, 'tipo_justificativa')
CargoBancadaCrud = CrudAux.build(CargoBancada, '')
TipoResultadoVotacaoCrud = CrudAux.build(
@@ -467,6 +466,23 @@ def get_presencas_generic(model, sessao, legislatura):
yield (m.parlamentar, False)
+class TipoExpedienteCrud(CrudAux):
+ model = TipoExpediente
+
+ class DeleteView(CrudAux.DeleteView):
+
+ def delete(self, *args, **kwargs):
+ self.object = self.get_object()
+
+ # Se todas as referências a este tipo forem de conteúdo vazio,
+ # significa que pode ser apagado
+ if self.object.expedientesessao_set.filter(conteudo='').count() == \
+ self.object.expedientesessao_set.all().count():
+ self.object.expedientesessao_set.all().delete()
+
+ return CrudAux.DeleteView.delete(self, *args, **kwargs)
+
+
class MateriaOrdemDiaCrud(MasterDetailCrud):
model = OrdemDia
parent_field = 'sessao_plenaria'
diff --git a/sapl/templates/sessao/blocos_ata/expedientes.html b/sapl/templates/sessao/blocos_ata/expedientes.html
index 1824e4836..cb118a34c 100644
--- a/sapl/templates/sessao/blocos_ata/expedientes.html
+++ b/sapl/templates/sessao/blocos_ata/expedientes.html
@@ -3,12 +3,10 @@
{% if expedientes %}
Expedientes:
{% for e in expedientes %}
- {{e.tipo}}:
- {% if e.conteudo %}
- {{e.conteudo|striptags|safe}}
- {% else %}
- Sem registro
- {% endif %}
+ {% if e.conteudo %}
+ {{e.tipo}}:
+ {{e.conteudo|striptags|safe}}
+ {% endif %}
{% endfor %}
{% endif %}
diff --git a/sapl/templates/sessao/blocos_resumo/expedientes.html b/sapl/templates/sessao/blocos_resumo/expedientes.html
index c76861726..d8a186469 100644
--- a/sapl/templates/sessao/blocos_resumo/expedientes.html
+++ b/sapl/templates/sessao/blocos_resumo/expedientes.html
@@ -4,14 +4,16 @@
{% for e in expedientes %}
-
-
- {{e.tipo}}:
-
- |
-
+ {% if e.conteudo %}
+
+
+ {{e.tipo}}:
+
+ |
+
+ {% endif %}
{% endfor %}