Browse Source

Fix #2515 (#2516)

pull/2534/head
Vinícius Cantuária 6 years ago
committed by Edward
parent
commit
0ceab96674
  1. 34
      sapl/audiencia/migrations/0010_auto_20190219_1511.py
  2. 30
      sapl/audiencia/models.py

34
sapl/audiencia/migrations/0010_auto_20190219_1511.py

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-02-19 18:11
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
import sapl.utils
class Migration(migrations.Migration):
dependencies = [
('audiencia', '0009_remove_anexoaudienciapublica_indexacao'),
]
operations = [
migrations.AlterField(
model_name='anexoaudienciapublica',
name='arquivo',
field=models.FileField(default='Assunto não existente.', upload_to=sapl.utils.texto_upload_path, verbose_name='Arquivo'),
preserve_default=False,
),
migrations.AlterField(
model_name='anexoaudienciapublica',
name='assunto',
field=models.TextField(verbose_name='Assunto'),
),
migrations.AlterField(
model_name='anexoaudienciapublica',
name='data',
field=models.DateField(auto_now=True, default=django.utils.timezone.now),
preserve_default=False,
),
]

30
sapl/audiencia/models.py

@ -155,13 +155,12 @@ class AnexoAudienciaPublica(models.Model):
audiencia = models.ForeignKey(AudienciaPublica,
on_delete=models.PROTECT)
arquivo = models.FileField(
blank=True,
null=True,
upload_to=texto_upload_path,
verbose_name=_('Arquivo'))
data = models.DateField(auto_now=timezone.now,blank=True, null=True)
data = models.DateField(
auto_now=timezone.now)
assunto = models.TextField(
blank=True, verbose_name=_('Assunto'))
verbose_name=_('Assunto'))
class Meta:
verbose_name = _('Anexo de Documento Acessório')
@ -174,22 +173,19 @@ class AnexoAudienciaPublica(models.Model):
if self.arquivo:
self.arquivo.delete()
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
return models.Model.delete(self, using=using, keep_parents=keep_parents)
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
if not self.pk and self.arquivo:
arquivo = self.arquivo
self.arquivo = None
models.Model.save(self, force_insert=force_insert,
force_update=force_update,
using=using,
update_fields=update_fields)
models.Model.save(
self,
force_insert=force_insert,
force_update=force_update,
using=using,
update_fields=update_fields)
self.arquivo = arquivo
return models.Model.save(self, force_insert=force_insert,
force_update=force_update,
using=using,
update_fields=update_fields)
return models.Model.save(self, force_insert=force_insert, force_update=force_update, using=using,
update_fields=update_fields)

Loading…
Cancel
Save