delete pdfs before deleting text object

This commit is contained in:
j 2013-02-19 16:44:27 +00:00
parent 051e1aff7e
commit d693fe66cc

View file

@ -9,6 +9,7 @@ from glob import glob
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.conf import settings from django.conf import settings
from django.db.models.signals import pre_delete
import ox import ox
from ox.django.fields import DictField, TupleField from ox.django.fields import DictField, TupleField
@ -168,6 +169,12 @@ class Text(models.Model):
return True return True
return False 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 Position(models.Model):
class Meta: class Meta: