fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
wyszukiwanie książek działa - narazie bez agregowania fragmentów.
[wolnelektury.git]
/
apps
/
catalogue
/
fields.py
diff --git
a/apps/catalogue/fields.py
b/apps/catalogue/fields.py
index
510c06d
..
0488244
100644
(file)
--- a/
apps/catalogue/fields.py
+++ b/
apps/catalogue/fields.py
@@
-122,9
+122,12
@@
class OverwritingFieldFile(FieldFile):
def save(self, name, content, *args, **kwargs):
leave = kwargs.pop('leave', None)
def save(self, name, content, *args, **kwargs):
leave = kwargs.pop('leave', None)
- if not leave and self and content is not self:
+ # delete if there's a file already and there's a new one coming
+ if not leave and self and (not hasattr(content, 'path') or
+ content.path != self.path):
self.delete(save=False)
self.delete(save=False)
- return super(OverwritingFieldFile, self).save(name, content, *args, **kwargs)
+ return super(OverwritingFieldFile, self).save(
+ name, content, *args, **kwargs)
class OverwritingFileField(models.FileField):
class OverwritingFileField(models.FileField):