fix deleting documents
This commit is contained in:
parent
76742c72fa
commit
d94b5d1db0
1 changed files with 3 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
|||
from __future__ import division, with_statement
|
||||
import os
|
||||
import re
|
||||
from glob import glob
|
||||
import subprocess
|
||||
from urllib import quote, unquote
|
||||
|
||||
|
@ -288,9 +289,9 @@ class Document(models.Model):
|
|||
def delete_document(sender, **kwargs):
|
||||
t = kwargs['instance']
|
||||
if t.file:
|
||||
folder = os.path.dirname(self.file.path)
|
||||
folder = os.path.dirname(t.file.path)
|
||||
for f in glob('%s/*' % folder):
|
||||
if f != self.file.path:
|
||||
if f != t.file.path:
|
||||
os.unlink(f)
|
||||
t.file.delete()
|
||||
pre_delete.connect(delete_document, sender=Document)
|
||||
|
|
Loading…
Reference in a new issue