Browse Source

Adiciona ordenação explícita para DocumentoAcessorio (#3287)

pull/3291/head
Vinícius Cantuária 4 years ago
committed by GitHub
parent
commit
2df3963d3e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      sapl/materia/migrations/0074_auto_20201006_0734.py
  2. 22
      sapl/materia/models.py

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

22
sapl/materia/models.py

@ -541,15 +541,10 @@ class TipoDocumento(models.Model):
@reversion.register() @reversion.register()
class DocumentoAcessorio(models.Model): class DocumentoAcessorio(models.Model):
materia = models.ForeignKey(MateriaLegislativa, on_delete=models.CASCADE) materia = models.ForeignKey(MateriaLegislativa, on_delete=models.CASCADE)
tipo = models.ForeignKey(TipoDocumento, tipo = models.ForeignKey(TipoDocumento, on_delete=models.PROTECT, verbose_name=_('Tipo'))
on_delete=models.PROTECT,
verbose_name=_('Tipo'))
nome = models.CharField(max_length=50, verbose_name=_('Nome')) nome = models.CharField(max_length=50, verbose_name=_('Nome'))
data = models.DateField(blank=True, null=True, default=None, verbose_name=_('Data'))
data = models.DateField(blank=True, null=True, autor = models.CharField(max_length=200, blank=True, verbose_name=_('Autor'))
default=None, verbose_name=_('Data'))
autor = models.CharField(
max_length=200, blank=True, verbose_name=_('Autor'))
ementa = models.TextField(blank=True, verbose_name=_('Ementa')) ementa = models.TextField(blank=True, verbose_name=_('Ementa'))
indexacao = models.TextField(blank=True) indexacao = models.TextField(blank=True)
arquivo = models.FileField( arquivo = models.FileField(
@ -560,18 +555,13 @@ class DocumentoAcessorio(models.Model):
verbose_name=_('Texto Integral'), verbose_name=_('Texto Integral'),
storage=OverwriteStorage(), storage=OverwriteStorage(),
validators=[restringe_tipos_de_arquivo_txt]) validators=[restringe_tipos_de_arquivo_txt])
proposicao = GenericRelation('Proposicao', related_query_name='proposicao')
proposicao = GenericRelation( data_ultima_atualizacao = models.DateTimeField(blank=True, null=True, auto_now=True, verbose_name=_('Data'))
'Proposicao', related_query_name='proposicao')
data_ultima_atualizacao = models.DateTimeField(
blank=True, null=True,
auto_now=True,
verbose_name=_('Data'))
class Meta: class Meta:
verbose_name = _('Documento Acessório') verbose_name = _('Documento Acessório')
verbose_name_plural = _('Documentos Acessórios') verbose_name_plural = _('Documentos Acessórios')
ordering = ('data', '-data_ultima_atualizacao')
def __str__(self): def __str__(self):
return _('%(tipo)s - %(nome)s de %(data)s por %(autor)s') % { return _('%(tipo)s - %(nome)s de %(data)s por %(autor)s') % {

Loading…
Cancel
Save