diff --git a/sapl/norma/migrations/0023_auto_20190219_1535.py b/sapl/norma/migrations/0023_auto_20190219_1535.py new file mode 100644 index 000000000..badf71a81 --- /dev/null +++ b/sapl/norma/migrations/0023_auto_20190219_1535.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-02-19 18:35 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0022_auto_20190108_1606'), + ] + + operations = [ + migrations.AlterModelOptions( + name='normarelacionada', + options={'ordering': ('norma_principal__ano', 'norma_relacionada__ano'), 'verbose_name': 'Norma Relacionada', 'verbose_name_plural': 'Normas Relacionadas'}, + ), + ] diff --git a/sapl/norma/models.py b/sapl/norma/models.py index eef004d4f..f7fcf17e9 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -145,9 +145,11 @@ class NormaJuridica(models.Model): def get_normas_relacionadas(self): principais = NormaRelacionada.objects.filter( - norma_principal=self.id) + norma_principal=self.id).order_by('norma_principal__ano', + 'norma_relacionada__ano') relacionadas = NormaRelacionada.objects.filter( - norma_relacionada=self.id) + norma_relacionada=self.id).order_by('norma_principal__ano', + 'norma_relacionada__ano') return (principais, relacionadas) def get_anexos_norma_juridica(self): @@ -311,6 +313,7 @@ class NormaRelacionada(models.Model): class Meta: verbose_name = _('Norma Relacionada') verbose_name_plural = _('Normas Relacionadas') + ordering = ('norma_principal__ano', 'norma_relacionada__ano') def __str__(self): return _('Principal: %(norma_principal)s'