diff --git a/sapl/norma/migrations/0034_auto_20170222_1435.py b/sapl/norma/migrations/0034_auto_20170222_1435.py new file mode 100644 index 000000000..1fbb85152 --- /dev/null +++ b/sapl/norma/migrations/0034_auto_20170222_1435.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2017-02-22 14:35 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0033_auto_20170203_1019'), + ] + + operations = [ + migrations.RemoveField( + model_name='vinculonormajuridica', + name='descricao', + ), + migrations.AddField( + model_name='vinculonormajuridica', + name='descricao_ativa', + field=models.CharField(blank=True, max_length=50, verbose_name='Descrição Ativa'), + ), + migrations.AddField( + model_name='vinculonormajuridica', + name='descricao_passiva', + field=models.CharField(blank=True, max_length=50, verbose_name='Descrição Passiva'), + ), + ] diff --git a/sapl/norma/migrations/0035_auto_20170222_1438.py b/sapl/norma/migrations/0035_auto_20170222_1438.py new file mode 100644 index 000000000..e8b1c0ddc --- /dev/null +++ b/sapl/norma/migrations/0035_auto_20170222_1438.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2017-02-22 14:38 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0034_auto_20170222_1435'), + ] + + operations = [ + migrations.RenameModel( + old_name='VinculoNormaJuridica', + new_name='TipoVinculoNormaJuridica', + ), + ] diff --git a/sapl/norma/models.py b/sapl/norma/models.py index 6abf975c4..a36368e8b 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -181,18 +181,20 @@ class LegislacaoCitada(models.Model): return str(self.norma) -class VinculoNormaJuridica(models.Model): +class TipoVinculoNormaJuridica(models.Model): sigla = models.CharField( max_length=1, blank=True, verbose_name=_('Sigla')) - descricao = models.CharField( - max_length=50, blank=True, verbose_name=_('Descrição')) + descricao_ativa = models.CharField( + max_length=50, blank=True, verbose_name=_('Descrição Ativa')) + descricao_passiva = models.CharField( + max_length=50, blank=True, verbose_name=_('Descrição Passiva')) class Meta: verbose_name = _('Tipo de Vínculo entre Normas Jurídicas') verbose_name_plural = _('Tipos de Vínculos entre Normas Jurídicas') def __str__(self): - return self.descricao + return self.descricao_ativa class NormaRelacionada(models.Model): @@ -205,7 +207,7 @@ class NormaRelacionada(models.Model): related_name='norma_relacionada', verbose_name=_('Norma Relacionada')) tipo_vinculo = models.ForeignKey( - VinculoNormaJuridica, verbose_name=_('Tipo de Vínculo')) + TipoVinculoNormaJuridica, verbose_name=_('Tipo de Vínculo')) class Meta: verbose_name = _('Norma Relacionada') diff --git a/sapl/norma/urls.py b/sapl/norma/urls.py index 59d8f3473..4d434d42b 100644 --- a/sapl/norma/urls.py +++ b/sapl/norma/urls.py @@ -2,7 +2,7 @@ from django.conf.urls import include, url from sapl.norma.views import (AssuntoNormaCrud, NormaCrud, NormaPesquisaView, NormaRelacionadaCrud, NormaTaView, TipoNormaCrud, - VinculoNormaJuridicaCrud, recuperar_norma) + TipoVinculoNormaJuridicaCrud, recuperar_norma) from .apps import AppConfig @@ -19,7 +19,7 @@ urlpatterns = [ url(r'^sistema/norma/tipo/', include(TipoNormaCrud.get_urls())), url(r'^sistema/norma/assunto/', include(AssuntoNormaCrud.get_urls())), url(r'^sistema/norma/vinculo/', include( - VinculoNormaJuridicaCrud.get_urls())), + TipoVinculoNormaJuridicaCrud.get_urls())), url(r'^norma/pesquisar$', NormaPesquisaView.as_view(), name='norma_pesquisa'), diff --git a/sapl/norma/views.py b/sapl/norma/views.py index f206b7dd7..bdb74c5e0 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -15,7 +15,7 @@ from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, from .forms import NormaFilterSet, NormaJuridicaForm, NormaRelacionadaForm from .models import (AssuntoNorma, NormaJuridica, NormaRelacionada, - TipoNormaJuridica, VinculoNormaJuridica) + TipoNormaJuridica, TipoVinculoNormaJuridica) # LegislacaoCitadaCrud = Crud.build(LegislacaoCitada, '') AssuntoNormaCrud = CrudAux.build(AssuntoNorma, 'assunto_norma_juridica', @@ -25,8 +25,9 @@ AssuntoNormaCrud = CrudAux.build(AssuntoNorma, 'assunto_norma_juridica', TipoNormaCrud = CrudAux.build( TipoNormaJuridica, 'tipo_norma_juridica', list_field_names=['sigla', 'descricao', 'equivalente_lexml']) -VinculoNormaJuridicaCrud = CrudAux.build( - VinculoNormaJuridica, '', list_field_names=['sigla', 'descricao']) +TipoVinculoNormaJuridicaCrud = CrudAux.build( + TipoVinculoNormaJuridica, '', + list_field_names=['sigla', 'descricao_ativa', 'descricao_passiva']) class NormaRelacionadaCrud(MasterDetailCrud): @@ -128,6 +129,18 @@ class NormaCrud(Crud): namespace = self.model._meta.app_config.name 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 + class DeleteView(Crud.DeleteView): def get_success_url(self): diff --git a/sapl/rules/map_rules.py b/sapl/rules/map_rules.py index 548eba0c4..4c96d3354 100644 --- a/sapl/rules/map_rules.py +++ b/sapl/rules/map_rules.py @@ -223,7 +223,7 @@ rules_group_geral = { (norma.AssuntoNorma, __base__), (norma.TipoNormaJuridica, __base__), - (norma.VinculoNormaJuridica, __base__), + (norma.TipoVinculoNormaJuridica, __base__), (parlamentares.Legislatura, __base__), (parlamentares.SessaoLegislativa, __base__), diff --git a/sapl/templates/norma/layouts.yaml b/sapl/templates/norma/layouts.yaml index 52d16d587..a613415bc 100644 --- a/sapl/templates/norma/layouts.yaml +++ b/sapl/templates/norma/layouts.yaml @@ -50,9 +50,9 @@ LegislacaoCitadaDetail: - capitulo secao subsecao artigo - paragrafo inciso alinea item -VinculoNormaJuridica: +TipoVinculoNormaJuridica: {% trans 'Tipo de Vínculo entre Normas Jurídicas' %}: - - sigla:2 descricao + - sigla:2 descricao_ativa descricao_passiva NormaRelacionada: {% trans 'Norma Relacionada' %}: diff --git a/sapl/templates/norma/normajuridica_detail.html b/sapl/templates/norma/normajuridica_detail.html index c363549a0..821850eec 100644 --- a/sapl/templates/norma/normajuridica_detail.html +++ b/sapl/templates/norma/normajuridica_detail.html @@ -12,7 +12,7 @@

{{ column.verbose_name }}

{% comment %}TODO Transformar os links em URLs diretamente no CRUD{% endcomment %} - + {% if column.text|url %}
{{ column.text|safe }}
{% elif column.verbose_name == 'Matéria' %} @@ -31,4 +31,32 @@
{% endfor %} {% endfor %} -{% endblock detail_content %} \ No newline at end of file + +
+
+
+

Relacionamentos

+ {% if principais|length > 0 %} + {% for p in principais %} +
+ {{ p.tipo_vinculo.descricao_passiva }}  + + {{ p.norma_relacionada }} + +
+ {% endfor %} + {% endif %} + + {% if relacionadas|length > 0 %} + {% for r in relacionadas %} +
+ {{ r.tipo_vinculo.descricao_ativa }}  + + {{ r.norma_principal }} + +
+ {% endfor %} + {% endif %} +
+
+{% endblock detail_content %} diff --git a/sapl/templates/sistema.html b/sapl/templates/sistema.html index 6b9d1f5d4..cc6cddfc0 100644 --- a/sapl/templates/sistema.html +++ b/sapl/templates/sistema.html @@ -71,7 +71,7 @@
Tipo de Norma Jurídica
Assunto de Norma Jurídica
-
Tipo de Vínculo
+
Tipo de Vínculo