Browse Source

Fix #409

pull/907/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
30f9ca5ec9
  1. 29
      sapl/norma/migrations/0034_auto_20170222_1435.py
  2. 19
      sapl/norma/migrations/0035_auto_20170222_1438.py
  3. 12
      sapl/norma/models.py
  4. 4
      sapl/norma/urls.py
  5. 19
      sapl/norma/views.py
  6. 2
      sapl/rules/map_rules.py
  7. 4
      sapl/templates/norma/layouts.yaml
  8. 32
      sapl/templates/norma/normajuridica_detail.html
  9. 2
      sapl/templates/sistema.html

29
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'),
),
]

19
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',
),
]

12
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')

4
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'),

19
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):

2
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__),

4
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' %}:

32
sapl/templates/norma/normajuridica_detail.html

@ -12,7 +12,7 @@
<p class="control-label">{{ column.verbose_name }}</p>
<div class="controls">
{% comment %}TODO Transformar os links em URLs diretamente no CRUD{% endcomment %}
{% if column.text|url %}
<div class="form-control-static"><a href="{{ column.text|safe }}"> {{ column.text|safe }} </a></div>
{% elif column.verbose_name == 'Matéria' %}
@ -31,4 +31,32 @@
</div>
{% endfor %}
{% endfor %}
{% endblock detail_content %}
<hr />
<div class="row-fluid">
<div class="col-sm-12">
<p class="control-label">Relacionamentos</p>
{% if principais|length > 0 %}
{% for p in principais %}
<div class="form-control-static">
<b>{{ p.tipo_vinculo.descricao_passiva }}</b>&nbsp;
<a href="{% url 'sapl.norma:normajuridica_detail' p.norma_relacionada.pk %}">
{{ p.norma_relacionada }}
</a>
</div>
{% endfor %}
{% endif %}
{% if relacionadas|length > 0 %}
{% for r in relacionadas %}
<div class="form-control-static">
<b>{{ r.tipo_vinculo.descricao_ativa }}</b>&nbsp;
<a href="{% url 'sapl.norma:normajuridica_detail' r.norma_principal.pk %}">
{{ r.norma_principal }}
</a>
</div>
{% endfor %}
{% endif %}
</div>
</div>
{% endblock detail_content %}

2
sapl/templates/sistema.html

@ -71,7 +71,7 @@
<div class="row">
<div class="col-md-6"><a href="{% url 'sapl.norma:tiponormajuridica_list' %}" class="btn btn-link">Tipo de Norma Jurídica</a></div>
<div class="col-md-6"><a href="{% url 'sapl.norma:assuntonorma_list' %}" class="btn btn-link">Assunto de Norma Jurídica</a></div>
<div class="col-md-6"><a href="{% url 'sapl.norma:vinculonormajuridica_list' %}" class="btn btn-link">Tipo de Vínculo</a></div>
<div class="col-md-6"><a href="{% url 'sapl.norma:tipovinculonormajuridica_list' %}" class="btn btn-link">Tipo de Vínculo</a></div>
</div>
<hr />

Loading…
Cancel
Save