diff options
-rw-r--r-- | archaeological_finds/tests.py | 13 | ||||
-rw-r--r-- | ishtar_common/models.py | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index b44bc9979..a0c05dbe2 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -29,7 +29,7 @@ from ishtar_common.models import ImporterType, IshtarUser, ImporterColumn,\ FormaterType, ImportTarget, IshtarSiteProfile, ProfileType from ishtar_common.models import Person, get_current_profile, UserProfile, \ - Town, Area + Town, Area, IshtarImage from archaeological_context_records.models import Period, Dating, ContextRecord from archaeological_finds import models, views from archaeological_warehouse.models import Warehouse, WarehouseType @@ -713,7 +713,12 @@ class PackagingTest(FindInit, TestCase): self.create_finds(data_base={"label": u"Find 1"}, force=True) self.create_finds(data_base={"label": u"Find 2"}, force=True) - self.finds[0].image.save('ishtar-bg.jpg', File(open(img))) + image = IshtarImage.objects.create(name="Image!") + image.image.save('ishtar-bg.jpg', File(open(img))) + models.FindImage.objects.create( + item=self.finds[0], + image=image + ) self.finds[0].save() self.basket = models.FindBasket.objects.create( @@ -746,8 +751,8 @@ class PackagingTest(FindInit, TestCase): # image names used to be altered on save: check for this bug self.assertEqual( - resulting_find.image.name, - models.Find.objects.get(pk=first_find.pk).image.name + resulting_find.images.all()[0].name, + models.Find.objects.get(pk=first_find.pk).images.all()[0].name ) # new version of the find is in the basket diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 97af69417..b4a385b4e 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3183,7 +3183,8 @@ class IshtarImage(ImageModel): super(IshtarImage, self).save(*args, **kwargs) - if not no_path_change and not getattr(self, '_no_path_change', False): + if self.image and not no_path_change and \ + not getattr(self, '_no_path_change', False): links = self._move_image() links = self.LINK_SPLIT.join(links) if links != self.associated_links: |