diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-07 11:09:35 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 10:46:13 +0200 |
commit | 07f24f648504004adbb57b16bd18fbd23a3c3998 (patch) | |
tree | d605a5b6bc1aa62d20631a965fc6bd6fd341bc86 /archaeological_finds | |
parent | 5341c3beb0fc3b52e864156bbfee54db78612b20 (diff) | |
download | Ishtar-07f24f648504004adbb57b16bd18fbd23a3c3998.tar.bz2 Ishtar-07f24f648504004adbb57b16bd18fbd23a3c3998.zip |
Fix tests and fixtures for new document management (refs #4107)
Diffstat (limited to 'archaeological_finds')
-rw-r--r-- | archaeological_finds/forms.py | 2 | ||||
-rw-r--r-- | archaeological_finds/models_finds.py | 4 | ||||
-rw-r--r-- | archaeological_finds/tests.py | 24 |
3 files changed, 12 insertions, 18 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 1636c7897..82c7cc34e 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -455,7 +455,7 @@ class FindSelect(TableSelect): base_finds__batch = forms.ChoiceField( label=_(u"Batch/object"), choices=[]) checked = forms.ChoiceField(label=_("Check")) - images__pk__isnull = forms.NullBooleanField(label=_(u"Has an image?")) + documents__image__isnull = forms.NullBooleanField(label=_(u"Has an image?")) def __init__(self, *args, **kwargs): super(FindSelect, self).__init__(*args, **kwargs) diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index a217eb079..b269c0135 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -647,7 +647,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, ATTRS_EQUIV = {'get_first_base_find': 'base_finds'} # search parameters - REVERSED_BOOL_FIELDS = ['images__pk__isnull'] + REVERSED_BOOL_FIELDS = ['documents__image__isnull'] RELATION_TYPES_PREFIX = { 'ope_relation_types': 'base_finds__context_record__operation__', @@ -687,7 +687,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, 'base_finds__batch': 'base_finds__batch', 'basket': 'basket', 'cached_label': 'cached_label__icontains', - 'images__pk__isnull': 'images__pk__isnull', + 'documents__image__isnull': 'documents__image__isnull', 'container__location': 'container__location__pk', 'container__responsible': 'container__responsible__pk', 'container__index': 'container__index', diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 1843ff094..a4a1ad471 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, IshtarImage + Town, Area, Document from archaeological_context_records.models import Period, Dating, ContextRecord from archaeological_finds import models, views from archaeological_warehouse.models import Warehouse, WarehouseType @@ -277,7 +277,7 @@ class ImportFindTest(ImportTest, TestCase): importer_type_id=MCC.pk) formater = FormaterType.objects.filter( formater_type='FileFormater').all()[0] - ImportTarget.objects.create(target='images__image', + ImportTarget.objects.create(target='documents__image', formater_type_id=formater.pk, column_id=col.pk) mcc_file = open( @@ -636,21 +636,18 @@ class FindSearchTest(FindInit, TestCase): def test_image_search(self): c = Client() c.login(username=self.username, password=self.password) - search = {'images__pk__isnull': 2} # 2 for nullboolfield is None + search = {'documents__image__isnull': 2} # 2 for nullboolfield is None response = c.get(reverse('get-find'), search) self.assertEqual(response.status_code, 200) res = json.loads(response.content) self.assertEqual(res['recordsTotal'], 0) # add an image to the first find - image = IshtarImage.objects.create(name="Image!") + image = Document.objects.create(title="Image!") img = settings.ROOT_PATH + \ '../ishtar_common/static/media/images/ishtar-bg.jpg' image.image.save('ishtar-bg.jpg', File(open(img))) - models.FindImage.objects.create( - item=self.finds[0], - image=image - ) + self.finds[0].documents.add(image) self.finds[0].save() response = c.get(reverse('get-find'), search) self.assertEqual(response.status_code, 200) @@ -738,12 +735,9 @@ 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) - image = IshtarImage.objects.create(name="Image!") + image = Document.objects.create(title="Image!") image.image.save('ishtar-bg.jpg', File(open(img))) - models.FindImage.objects.create( - item=self.finds[0], - image=image - ) + self.finds[0].documents.add(image) self.finds[0].save() self.basket = models.FindBasket.objects.create( @@ -776,8 +770,8 @@ class PackagingTest(FindInit, TestCase): # image names used to be altered on save: check for this bug self.assertEqual( - resulting_find.images.all()[0].name, - models.Find.objects.get(pk=first_find.pk).images.all()[0].name + resulting_find.documents.all()[0].title, + models.Find.objects.get(pk=first_find.pk).documents.all()[0].title ) # new version of the find is in the basket |