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. 22
      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,
),
]

22
sapl/audiencia/models.py

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