summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-05-15 18:54:19 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-06-12 08:44:34 +0200
commitf437b5fbfbbf9bbd6088dc4ff39a4737c82f6439 (patch)
tree17a144f0d505f962db12ed91f113bab57e6ee27b
parent75952dfb3d591802164661325a949d8dbb9a3ac5 (diff)
downloadIshtar-f437b5fbfbbf9bbd6088dc4ff39a4737c82f6439.tar.bz2
Ishtar-f437b5fbfbbf9bbd6088dc4ff39a4737c82f6439.zip
Fix tests for M2M images
-rw-r--r--archaeological_finds/tests.py13
-rw-r--r--ishtar_common/models.py3
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: