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') % {