From fe74eeefc385fbce6cb6c63a53a208da74ea3e45 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 5 Sep 2011 20:14:38 +0200 Subject: [PATCH] fixes --- apps/catalogue/fields.py | 7 +++++-- apps/catalogue/tests/book_import.py | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) 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 ] -- 2.20.1