Documentos de captura não estão sendo apagados quando uma captura é apagada
felubra opened this issue · 0 comments
felubra commented
Solução: usar handler num sinal para apagar esses documentos:
@receiver(post_delete)
def delete_associated_documents(sender, **kwargs):
instance = kwargs['instance']
if hasattr(instance, '_delete_in_signal'):
return
if isinstance(instance, (NewsPDFCapture,)) or isinstance(instance, (NewsImageCapture,)):
try:
instance._delete_in_signal = True
if isinstance(instance, (NewsPDFCapture)):
instance.pdf_document.delete()
else:
instance.image_document.delete()
finally:
if hasattr(instance, '_delete_in_signal'):
del instance._delete_in_signal