From 2df3963d3eeac457fe6a2f6192eb277bcb6db2c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Cantu=C3=A1ria?= Date: Wed, 7 Oct 2020 11:57:15 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20ordena=C3=A7=C3=A3o=20expl=C3=ADcita?= =?UTF-8?q?=20para=20DocumentoAcessorio=20(#3287)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0074_auto_20201006_0734.py | 17 ++++++++++++++ sapl/materia/models.py | 22 +++++-------------- 2 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 sapl/materia/migrations/0074_auto_20201006_0734.py diff --git a/sapl/materia/migrations/0074_auto_20201006_0734.py b/sapl/materia/migrations/0074_auto_20201006_0734.py new file mode 100644 index 000000000..63397f721 --- /dev/null +++ b/sapl/materia/migrations/0074_auto_20201006_0734.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.13 on 2020-10-06 10:34 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('materia', '0073_auto_20200910_1420'), + ] + + operations = [ + migrations.AlterModelOptions( + name='documentoacessorio', + options={'ordering': ('data', '-data_ultima_atualizacao'), 'verbose_name': 'Documento Acessório', 'verbose_name_plural': 'Documentos Acessórios'}, + ), + ] diff --git a/sapl/materia/models.py b/sapl/materia/models.py index 0f17761bb..329cb8a5d 100644 --- a/sapl/materia/models.py +++ b/sapl/materia/models.py @@ -541,15 +541,10 @@ class TipoDocumento(models.Model): @reversion.register() class DocumentoAcessorio(models.Model): materia = models.ForeignKey(MateriaLegislativa, on_delete=models.CASCADE) - tipo = models.ForeignKey(TipoDocumento, - on_delete=models.PROTECT, - verbose_name=_('Tipo')) + tipo = models.ForeignKey(TipoDocumento, on_delete=models.PROTECT, verbose_name=_('Tipo')) nome = models.CharField(max_length=50, verbose_name=_('Nome')) - - data = models.DateField(blank=True, null=True, - default=None, verbose_name=_('Data')) - autor = models.CharField( - max_length=200, blank=True, verbose_name=_('Autor')) + data = models.DateField(blank=True, null=True, default=None, verbose_name=_('Data')) + autor = models.CharField(max_length=200, blank=True, verbose_name=_('Autor')) ementa = models.TextField(blank=True, verbose_name=_('Ementa')) indexacao = models.TextField(blank=True) arquivo = models.FileField( @@ -560,18 +555,13 @@ class DocumentoAcessorio(models.Model): verbose_name=_('Texto Integral'), storage=OverwriteStorage(), validators=[restringe_tipos_de_arquivo_txt]) - - proposicao = GenericRelation( - 'Proposicao', related_query_name='proposicao') - - data_ultima_atualizacao = models.DateTimeField( - blank=True, null=True, - auto_now=True, - verbose_name=_('Data')) + proposicao = GenericRelation('Proposicao', related_query_name='proposicao') + data_ultima_atualizacao = models.DateTimeField(blank=True, null=True, auto_now=True, verbose_name=_('Data')) class Meta: verbose_name = _('Documento Acessório') verbose_name_plural = _('Documentos Acessórios') + ordering = ('data', '-data_ultima_atualizacao') def __str__(self): return _('%(tipo)s - %(nome)s de %(data)s por %(autor)s') % {