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/2940/head
João Rodrigues 5 years ago
committed by Edward
parent
commit
3c5a33805a
  1. 30
      sapl/audiencia/models.py
  2. 31
      sapl/comissoes/models.py
  3. 30
      sapl/materia/models.py
  4. 19
      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 return self.nome
def delete(self, using=None, keep_parents=False): def delete(self, using=None, keep_parents=False):
if self.upload_pauta: upload_pauta = self.upload_pauta
self.upload_pauta.delete() upload_ata = self.upload_ata
upload_anexo = self.upload_anexo
result = super().delete(using=using, keep_parents=keep_parents)
if self.upload_ata: if upload_pauta:
self.upload_ata.delete() upload_pauta.delete(save=False)
if self.upload_anexo: if upload_ata:
self.upload_anexo.delete() upload_ata.delete(save=False)
return models.Model.delete( if upload_anexo:
self, using=using, keep_parents=keep_parents) upload_anexo.delete(save=False)
return result
def save(self, force_insert=False, force_update=False, using=None, def save(self, force_insert=False, force_update=False, using=None,
update_fields=None): update_fields=None):
@ -179,10 +184,13 @@ class AnexoAudienciaPublica(models.Model):
return self.assunto return self.assunto
def delete(self, using=None, keep_parents=False): def delete(self, using=None, keep_parents=False):
if self.arquivo: arquivo = self.arquivo
self.arquivo.delete() 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): 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:

31
sapl/comissoes/models.py

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

30
sapl/materia/models.py

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

19
sapl/norma/models.py

@ -190,11 +190,13 @@ class NormaJuridica(models.Model):
'data': defaultfilters.date(self.data, "d \d\e F \d\e Y")} 'data': defaultfilters.date(self.data, "d \d\e F \d\e Y")}
def delete(self, using=None, keep_parents=False): def delete(self, using=None, keep_parents=False):
if self.texto_integral: texto_integral = self.texto_integral
self.texto_integral.delete() result = super().delete(using=using, keep_parents=keep_parents)
if texto_integral:
texto_integral.delete(save=False)
return models.Model.delete( return result
self, using=using, keep_parents=keep_parents)
def save(self, force_insert=False, force_update=False, using=None, def save(self, force_insert=False, force_update=False, using=None,
update_fields=None): update_fields=None):
@ -389,3 +391,12 @@ class AnexoNormaJuridica(models.Model):
force_update=force_update, force_update=force_update,
using=using, 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): def delete(self, using=None, keep_parents=False):
if self.texto_integral: texto_integral = self.texto_integral
self.texto_integral.delete() result = super().delete(using=using, keep_parents=keep_parents)
if texto_integral:
texto_integral.delete(save=False)
return models.Model.delete( return result
self, using=using, keep_parents=keep_parents)
def save(self, force_insert=False, force_update=False, using=None, def save(self, force_insert=False, force_update=False, using=None,
update_fields=None): update_fields=None):
@ -251,11 +253,13 @@ class DocumentoAcessorioAdministrativo(models.Model):
return self.nome return self.nome
def delete(self, using=None, keep_parents=False): def delete(self, using=None, keep_parents=False):
if self.arquivo: arquivo = self.arquivo
self.arquivo.delete() result = super().delete(using=using, keep_parents=keep_parents)
if arquivo:
arquivo.delete(save=False)
return models.Model.delete( return result
self, using=using, keep_parents=keep_parents)
def save(self, force_insert=False, force_update=False, using=None, def save(self, force_insert=False, force_update=False, using=None,
update_fields=None): update_fields=None):

39
sapl/sessao/models.py

@ -262,17 +262,22 @@ class SessaoPlenaria(models.Model):
""" """
def delete(self, using=None, keep_parents=False): def delete(self, using=None, keep_parents=False):
if self.upload_pauta: upload_pauta = self.upload_pauta
self.upload_pauta.delete() upload_ata = self.upload_ata
upload_anexo = self.upload_anexo
if self.upload_ata: result = super().delete(using=using, keep_parents=keep_parents)
self.upload_ata.delete()
if self.upload_anexo: if upload_pauta:
self.upload_anexo.delete() upload_pauta.delete(save=False)
return models.Model.delete( if upload_ata:
self, using=using, keep_parents=keep_parents) 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, def save(self, force_insert=False, force_update=False, using=None,
update_fields=None): update_fields=None):
@ -445,6 +450,14 @@ class AbstractOrador(models.Model): # Oradores
'nome': self.parlamentar, 'nome': self.parlamentar,
'numero': self.numero_ordem} '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() @reversion.register()
class Orador(AbstractOrador): # Oradores class Orador(AbstractOrador): # Oradores
@ -789,11 +802,13 @@ class JustificativaAusencia(models.Model):
return 'Justificativa de Ausência' return 'Justificativa de Ausência'
def delete(self, using=None, keep_parents=False): def delete(self, using=None, keep_parents=False):
if self.upload_anexo: upload_anexo = self.upload_anexo
self.upload_anexo.delete() result = super().delete(using=using, keep_parents=keep_parents)
if upload_anexo:
upload_anexo.delete(save=False)
return models.Model.delete( return result
self, using=using, keep_parents=keep_parents)
def save(self, force_insert=False, force_update=False, using=None, def save(self, force_insert=False, force_update=False, using=None,
update_fields=None): update_fields=None):

Loading…
Cancel
Save