Browse Source

Fix #2691 - Exclusão de Arquivos (#3003)

* Fix #2961 - AudienciaPublica

* Fix #2961 - AnexoAudienciaPublica

* Fix #2961 - Reuniao

* Fix #2961 - DocumentoAcessorio

* Fix #2961 - MateriaLegislativa

* Fix #2961 - DocumentoAcessorio (sapl/materia)

* Fix #2961 - Proposicao

* Fix #2961 - NormaJuridica

* Fix #2961 - AnexoNormaJuridica

* Fix #2961 - DocumentoAdministrativo

* Fix #2961 - DocumentoAcessorioAdministrativo

* Fix #2961 - SessaoPlenaria

* Fix #2961 - AbstractOrador

* Fix #2961 - JustificativaAusencia
pull/3024/head
João Rodrigues 5 years ago
committed by Cesar Carvalho
parent
commit
5dcb012f0b
  1. 30
      sapl/audiencia/models.py
  2. 31
      sapl/comissoes/models.py
  3. 30
      sapl/materia/models.py
  4. 21
      sapl/norma/models.py
  5. 20
      sapl/protocoloadm/models.py
  6. 39
      sapl/sessao/models.py

30
sapl/audiencia/models.py

@ -119,17 +119,22 @@ class AudienciaPublica(models.Model):
return self.nome
def delete(self, using=None, keep_parents=False):
if self.upload_pauta:
self.upload_pauta.delete()
upload_pauta = self.upload_pauta
upload_ata = self.upload_ata
upload_anexo = self.upload_anexo
if self.upload_ata:
self.upload_ata.delete()
result = super().delete(using=using, keep_parents=keep_parents)
if self.upload_anexo:
self.upload_anexo.delete()
if upload_pauta:
upload_pauta.delete(save=False)
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
if upload_ata:
upload_ata.delete(save=False)
if upload_anexo:
upload_anexo.delete(save=False)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
@ -179,10 +184,13 @@ class AnexoAudienciaPublica(models.Model):
return self.assunto
def delete(self, using=None, keep_parents=False):
if self.arquivo:
self.arquivo.delete()
arquivo = self.arquivo
result = super().delete(using=using, keep_parents=keep_parents)
if arquivo:
arquivo.delete(save=False)
return models.Model.delete(self, using=using, keep_parents=keep_parents)
return result
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
if not self.pk and self.arquivo:

31
sapl/comissoes/models.py

@ -264,17 +264,22 @@ class Reuniao(models.Model):
return self.nome
def delete(self, using=None, keep_parents=False):
if self.upload_pauta:
self.upload_pauta.delete()
upload_pauta = self.upload_pauta
upload_ata = self.upload_ata
upload_anexo = self.upload_anexo
if self.upload_ata:
self.upload_ata.delete()
result = super().delete(using=using, keep_parents=keep_parents)
if self.upload_anexo:
self.upload_anexo.delete()
if upload_pauta:
upload_pauta.delete(save=False)
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
if upload_ata:
upload_ata.delete(save=False)
if upload_anexo:
upload_anexo.delete(save=False)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
@ -339,11 +344,13 @@ class DocumentoAcessorio(models.Model):
'autor': self.autor}
def delete(self, using=None, keep_parents=False):
if self.arquivo:
self.arquivo.delete()
arquivo = self.arquivo
result = super().delete(using=using, keep_parents=keep_parents)
if arquivo:
arquivo.delete(save=False)
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):

30
sapl/materia/models.py

@ -338,16 +338,18 @@ class MateriaLegislativa(models.Model):
return ''
def delete(self, using=None, keep_parents=False):
if self.texto_original:
self.texto_original.delete()
texto_original = self.texto_original
result = super().delete(using=using, keep_parents=keep_parents)
if texto_original:
texto_original.delete(save=False)
for p in self.proposicao.all():
p.conteudo_gerado_related = None
p.cancelado = True
p.save()
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
@ -566,15 +568,17 @@ class DocumentoAcessorio(models.Model):
'autor': self.autor}
def delete(self, using=None, keep_parents=False):
if self.arquivo:
self.arquivo.delete()
arquivo = self.arquivo
result = super().delete(using=using, keep_parents=keep_parents)
if arquivo:
arquivo.delete(save=False)
for p in self.proposicao.all():
p.conteudo_gerado_related = None
p.save()
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
@ -910,11 +914,13 @@ class Proposicao(models.Model):
)}
def delete(self, using=None, keep_parents=False):
if self.texto_original:
self.texto_original.delete()
texto_original = self.texto_original
result = super().delete(using=using, keep_parents=keep_parents)
if texto_original:
texto_original.delete(save=False)
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):

21
sapl/norma/models.py

@ -197,11 +197,13 @@ class NormaJuridica(models.Model):
'data': defaultfilters.date(self.data, "d \d\e F \d\e Y")}
def delete(self, using=None, keep_parents=False):
if self.texto_integral:
self.texto_integral.delete()
texto_integral = self.texto_integral
result = super().delete(using=using, keep_parents=keep_parents)
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
if texto_integral:
texto_integral.delete(save=False)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
@ -395,4 +397,13 @@ class AnexoNormaJuridica(models.Model):
return models.Model.save(self, force_insert=force_insert,
force_update=force_update,
using=using,
update_fields=update_fields)
update_fields=update_fields)
def delete(self, using=None, keep_parents=False):
anexo_arquivo = self.anexo_arquivo
result = super().delete(using=using, keep_parents=keep_parents)
if anexo_arquivo:
anexo_arquivo.delete(save=False)
return result

20
sapl/protocoloadm/models.py

@ -196,11 +196,13 @@ class DocumentoAdministrativo(models.Model):
}
def delete(self, using=None, keep_parents=False):
if self.texto_integral:
self.texto_integral.delete()
texto_integral = self.texto_integral
result = super().delete(using=using, keep_parents=keep_parents)
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
if texto_integral:
texto_integral.delete(save=False)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
@ -251,11 +253,13 @@ class DocumentoAcessorioAdministrativo(models.Model):
return self.nome
def delete(self, using=None, keep_parents=False):
if self.arquivo:
self.arquivo.delete()
arquivo = self.arquivo
result = super().delete(using=using, keep_parents=keep_parents)
if arquivo:
arquivo.delete(save=False)
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):

39
sapl/sessao/models.py

@ -207,17 +207,22 @@ class SessaoPlenaria(models.Model):
"""
def delete(self, using=None, keep_parents=False):
if self.upload_pauta:
self.upload_pauta.delete()
upload_pauta = self.upload_pauta
upload_ata = self.upload_ata
upload_anexo = self.upload_anexo
result = super().delete(using=using, keep_parents=keep_parents)
if self.upload_ata:
self.upload_ata.delete()
if upload_pauta:
upload_pauta.delete(save=False)
if self.upload_anexo:
self.upload_anexo.delete()
if upload_ata:
upload_ata.delete(save=False)
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
if upload_anexo:
upload_anexo.delete(save=False)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
@ -390,6 +395,14 @@ class AbstractOrador(models.Model): # Oradores
'nome': self.parlamentar,
'numero': self.numero_ordem}
def delete(self, using=None, keep_parents=False):
upload_anexo = self.upload_anexo
result = super().delete(using=using, keep_parents=keep_parents)
if upload_anexo:
upload_anexo.delete(save=False)
return result
@reversion.register()
class Orador(AbstractOrador): # Oradores
@ -734,11 +747,13 @@ class JustificativaAusencia(models.Model):
return 'Justificativa de Ausência'
def delete(self, using=None, keep_parents=False):
if self.upload_anexo:
self.upload_anexo.delete()
upload_anexo = self.upload_anexo
result = super().delete(using=using, keep_parents=keep_parents)
if upload_anexo:
upload_anexo.delete(save=False)
return models.Model.delete(
self, using=using, keep_parents=keep_parents)
return result
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):

Loading…
Cancel
Save