From d693fe66cc208cf51c827aed94befe5f053e8ff4 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 19 Feb 2013 16:44:27 +0000 Subject: [PATCH] delete pdfs before deleting text object --- pandora/text/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandora/text/models.py b/pandora/text/models.py index a0248f3de..dbf020473 100644 --- a/pandora/text/models.py +++ b/pandora/text/models.py @@ -9,6 +9,7 @@ from glob import glob from django.db import models from django.contrib.auth.models import User from django.conf import settings +from django.db.models.signals import pre_delete import ox from ox.django.fields import DictField, TupleField @@ -168,6 +169,12 @@ class Text(models.Model): return True return False +def delete_file(sender, **kwargs): + t = kwargs['instance'] + if t.file: + t.file.delete() +pre_delete.connect(delete_file, sender=Text) + class Position(models.Model): class Meta: