diff --git a/sapl/audiencia/forms.py b/sapl/audiencia/forms.py
index adab88db6..d2c7dd45b 100755
--- a/sapl/audiencia/forms.py
+++ b/sapl/audiencia/forms.py
@@ -115,7 +115,7 @@ class AudienciaForm(FileFieldCheckMixin, forms.ModelForm):
numero=materia,
ano=ano_materia,
tipo=tipo_materia)
- except ObjectDoesNotExist:
+ except (ObjectDoesNotExist, ValueError):
msg = _('A matéria %s nº %s/%s não existe no cadastro'
' de matérias legislativas.' % (tipo_materia, materia, ano_materia))
self.logger.warning(
diff --git a/sapl/relatorios/forms.py b/sapl/relatorios/forms.py
index 23145f899..f659c254c 100644
--- a/sapl/relatorios/forms.py
+++ b/sapl/relatorios/forms.py
@@ -633,6 +633,8 @@ class RelatorioMateriasPorAutorFilterSet(django_filters.FilterSet):
@property
def qs(self):
parent = super().qs
+ if not self.data.get('autoria__autor'):
+ return parent.none()
return parent.distinct().order_by('-ano', '-numero', 'tipo', 'autoria__autor', '-autoria__primeiro_autor')
class Meta(FilterOverridesMetaMixin):
@@ -744,7 +746,9 @@ class RelatorioNormasPorAutorFilterSet(django_filters.FilterSet):
@property
def qs(self):
parent = super().qs
- return parent.distinct().filter(autorianorma__primeiro_autor=True) \
+ if not self.data.get('autorianorma__autor'):
+ return parent.none()
+ return parent.distinct() \
.order_by('autorianorma__autor', '-autorianorma__primeiro_autor', 'tipo', '-ano', '-numero')
class Meta(FilterOverridesMetaMixin):
diff --git a/sapl/relatorios/views.py b/sapl/relatorios/views.py
index 1fd2c5a0c..abb1866b8 100755
--- a/sapl/relatorios/views.py
+++ b/sapl/relatorios/views.py
@@ -2660,7 +2660,6 @@ class RelatorioMateriasPorAutorView(RelatorioMixin, FilterView):
return context
qs = context['object_list']
- context['materias_resultado'] = list(collections.OrderedDict.fromkeys(qs))
context['qtdes'] = num_materias_por_tipo(qs)
qr = self.request.GET.copy()
@@ -2675,9 +2674,9 @@ class RelatorioMateriasPorAutorView(RelatorioMixin, FilterView):
context['tipo'] = ''
if self.request.GET['autoria__autor']:
autor = int(self.request.GET['autoria__autor'])
- context['autor'] = (str(Autor.objects.get(id=autor)))
+ context['autor'] = Autor.objects.get(id=autor)
else:
- context['autor'] = ''
+ context['autor'] = None
context['periodo'] = (
self.request.GET['data_apresentacao_0'] +
' - ' + self.request.GET['data_apresentacao_1'])
@@ -2921,9 +2920,9 @@ class RelatorioNormasPorAutorView(RelatorioMixin, FilterView):
if self.request.GET['autorianorma__autor']:
autor = int(self.request.GET['autorianorma__autor'])
- context['autor'] = (str(Autor.objects.get(id=autor)))
+ context['autor'] = Autor.objects.get(id=autor)
else:
- context['autor'] = ''
+ context['autor'] = None
context['periodo'] = (
self.request.GET['data_0'] +
' - ' + self.request.GET['data_1'])
diff --git a/sapl/templates/relatorios/RelatorioMateriasPorAutor_filter.html b/sapl/templates/relatorios/RelatorioMateriasPorAutor_filter.html
index 5acb303c1..dcd7287e0 100644
--- a/sapl/templates/relatorios/RelatorioMateriasPorAutor_filter.html
+++ b/sapl/templates/relatorios/RelatorioMateriasPorAutor_filter.html
@@ -17,7 +17,7 @@
Tipo de matéria: {{ tipo }}
Data de apresentação: {{ periodo }}
- {% if materias_resultado %}
+ {% if object_list %}
| Matéria | Ementa | -Autor(es) | +Coautor(es) | |
|---|---|---|---|---|
| @@ -56,11 +56,9 @@ | {% autoescape off %}{{materia.ementa}} {{materia.observacao}}{% endautoescape %} |
- {% for autor in materia.autoria_set.all %}
- {% if not autor.primeiro_autor %}
- {{ autor.autor }} - {% else %} - {{ autor.autor }} + {% for autoria in materia.autoria_set.all %} + {% if autoria.autor != autor %} + {{ autoria.autor }} {% endif %} {% endfor %} |
diff --git a/sapl/templates/relatorios/RelatorioNormasPorAutor_filter.html b/sapl/templates/relatorios/RelatorioNormasPorAutor_filter.html
index c3f045301..51c987c34 100644
--- a/sapl/templates/relatorios/RelatorioNormasPorAutor_filter.html
+++ b/sapl/templates/relatorios/RelatorioNormasPorAutor_filter.html
@@ -54,13 +54,11 @@
{% autoescape off %}{{norma.ementa}} {{norma.observacao}}{% endautoescape %} |
- {% if norma.autorianorma_set.first != norma.autorianorma_set.last %}
- {% for autor in norma.autorianorma_set.all %}
- {% if not autor.primeiro_autor %}
- {{ autor.autor }} + {% for autoria in norma.autorianorma_set.all %} + {% if autoria.autor != autor %} + {{ autoria.autor }} {% endif %} {% endfor %} - {% endif %} |