From 2740a91bf71abf689fbc7e4589db95b4d536fcd8 Mon Sep 17 00:00:00 2001 From: Ulysses Lara Date: Thu, 25 Apr 2019 13:57:48 -0300 Subject: [PATCH] Fix #2742 - BugFix ordenar normas relacionadas (#2750) * Fix #2742 - BugFix ordenar normas relacionadas * Add migration --- .../migrations/0024_auto_20190425_0917.py | 19 +++++++++++++++++++ sapl/norma/models.py | 10 +++++----- 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 sapl/norma/migrations/0024_auto_20190425_0917.py diff --git a/sapl/norma/migrations/0024_auto_20190425_0917.py b/sapl/norma/migrations/0024_auto_20190425_0917.py new file mode 100644 index 000000000..078bae0ee --- /dev/null +++ b/sapl/norma/migrations/0024_auto_20190425_0917.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-04-25 12:17 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0023_auto_20190219_1535'), + ] + + operations = [ + migrations.AlterModelOptions( + name='normarelacionada', + options={'ordering': ('norma_principal__data', 'norma_relacionada__data'), 'verbose_name': 'Norma Relacionada', 'verbose_name_plural': 'Normas Relacionadas'}, + ), + ] diff --git a/sapl/norma/models.py b/sapl/norma/models.py index 5a5557e5b..6b3a18a1f 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -145,11 +145,11 @@ class NormaJuridica(models.Model): def get_normas_relacionadas(self): principais = NormaRelacionada.objects.filter( - norma_principal=self.id).order_by('norma_principal__ano', - 'norma_relacionada__ano') + norma_principal=self.id).order_by('norma_principal__data', + 'norma_relacionada__data') relacionadas = NormaRelacionada.objects.filter( - norma_relacionada=self.id).order_by('norma_principal__ano', - 'norma_relacionada__ano') + norma_relacionada=self.id).order_by('norma_principal__data', + 'norma_relacionada__data') return (principais, relacionadas) def get_anexos_norma_juridica(self): @@ -313,7 +313,7 @@ class NormaRelacionada(models.Model): class Meta: verbose_name = _('Norma Relacionada') verbose_name_plural = _('Normas Relacionadas') - ordering = ('norma_principal__ano', 'norma_relacionada__ano') + ordering = ('norma_principal__data', 'norma_relacionada__data') def __str__(self): return _('Principal: %(norma_principal)s'