From: Radek Czajka Date: Mon, 5 Sep 2011 18:14:38 +0000 (+0200) Subject: fixes X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/fe74eeefc385fbce6cb6c63a53a208da74ea3e45?ds=sidebyside;hp=5c3d5246956dfe2abea0aa5c80f5e776cec72fa5 fixes --- diff --git a/apps/catalogue/fields.py b/apps/catalogue/fields.py index 510c06dac..048824498 100644 --- 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) - 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) - return super(OverwritingFieldFile, self).save(name, content, *args, **kwargs) + return super(OverwritingFieldFile, self).save( + name, content, *args, **kwargs) class OverwritingFileField(models.FileField): diff --git a/apps/catalogue/tests/book_import.py b/apps/catalogue/tests/book_import.py index c062b3219..57dbf27a3 100644 --- a/apps/catalogue/tests/book_import.py +++ b/apps/catalogue/tests/book_import.py @@ -43,7 +43,6 @@ class BookImportLogicTests(WLTestCase): # TODO: this should be filled out probably... self.assertEqual(book.wiki_link, '') self.assertEqual(book.gazeta_link, '') - self.assertEqual(book._short_html, '') self.assertEqual(book.description, '') tags = [ (tag.category, tag.slug) for tag in book.tags ]