From a011517ca33882db5430a4b524e1dcebb96f80c3 Mon Sep 17 00:00:00 2001 From: Edward Date: Wed, 20 Feb 2019 08:47:48 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20ordena=C3=A7=C3=A3o=20em=20normas=20?= =?UTF-8?q?(#2524)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0023_auto_20190219_1535.py | 19 +++++++++++++++++++ sapl/norma/models.py | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 sapl/norma/migrations/0023_auto_20190219_1535.py 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'