From b47b10835b74fe4e197071a1ed4dca6ca6fdc3a3 Mon Sep 17 00:00:00 2001 From: Edward Date: Tue, 7 Mar 2017 20:31:50 -0300 Subject: [PATCH] Fixes #913 (#917) --- sapl/norma/models.py | 7 +++++++ sapl/norma/views.py | 11 +--------- .../templates/norma/normajuridica_detail.html | 9 +++++---- .../templates/norma/normajuridica_filter.html | 20 +++++++++++++++++++ 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/sapl/norma/models.py b/sapl/norma/models.py index a36368e8b..8d5dbce82 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -114,6 +114,13 @@ class NormaJuridica(models.Model): verbose_name_plural = _('Normas Jurídicas') ordering = ['-data', '-numero'] + def get_normas_relacionadas(self): + principais = NormaRelacionada.objects.filter( + norma_principal=self.id) + relacionadas = NormaRelacionada.objects.filter( + norma_relacionada=self.id) + return (principais, relacionadas) + def __str__(self): return _('%(tipo)s nº %(numero)s de %(data)s') % { 'tipo': self.tipo, diff --git a/sapl/norma/views.py b/sapl/norma/views.py index bdb74c5e0..10dbf4ad2 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -130,16 +130,7 @@ class NormaCrud(Crud): return reverse('%s:%s' % (namespace, 'norma_pesquisa')) class DetailView(Crud.DetailView): - - def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - principais = NormaRelacionada.objects.filter( - norma_principal=self.object.pk) - relacionadas = NormaRelacionada.objects.filter( - norma_relacionada=self.object.pk) - context['principais'] = principais - context['relacionadas'] = relacionadas - return context + pass class DeleteView(Crud.DeleteView): diff --git a/sapl/templates/norma/normajuridica_detail.html b/sapl/templates/norma/normajuridica_detail.html index 4e2585988..ab1df921e 100644 --- a/sapl/templates/norma/normajuridica_detail.html +++ b/sapl/templates/norma/normajuridica_detail.html @@ -36,8 +36,9 @@