forked from 0x2620/pandora
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
|
from __future__ import division, with_statement
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from glob import glob
|
||||||
import subprocess
|
import subprocess
|
||||||
from urllib import quote, unquote
|
from urllib import quote, unquote
|
||||||
|
|
||||||
|
@ -288,9 +289,9 @@ class Document(models.Model):
|
||||||
def delete_document(sender, **kwargs):
|
def delete_document(sender, **kwargs):
|
||||||
t = kwargs['instance']
|
t = kwargs['instance']
|
||||||
if t.file:
|
if t.file:
|
||||||
folder = os.path.dirname(self.file.path)
|
folder = os.path.dirname(t.file.path)
|
||||||
for f in glob('%s/*' % folder):
|
for f in glob('%s/*' % folder):
|
||||||
if f != self.file.path:
|
if f != t.file.path:
|
||||||
os.unlink(f)
|
os.unlink(f)
|
||||||
t.file.delete()
|
t.file.delete()
|
||||||
pre_delete.connect(delete_document, sender=Document)
|
pre_delete.connect(delete_document, sender=Document)
|
||||||
|
|
Loading…
Reference in a new issue