diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-05-28 11:31:04 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-17 13:21:28 +0200 |
commit | 096bf9a3dcee0d72dba4c6c9f3802a02ac6d4d12 (patch) | |
tree | e19f1dfa26f4547001189721a89f0a5cbe036c57 /archaeological_finds | |
parent | 7587c316830be2c2866b2feeec4b44d081847338 (diff) | |
download | Ishtar-096bf9a3dcee0d72dba4c6c9f3802a02ac6d4d12.tar.bz2 Ishtar-096bf9a3dcee0d72dba4c6c9f3802a02ac6d4d12.zip |
Fix cache generation for finds and context records
Diffstat (limited to 'archaeological_finds')
-rw-r--r-- | archaeological_finds/models_finds.py | 16 | ||||
-rw-r--r-- | archaeological_finds/tests.py | 4 |
2 files changed, 15 insertions, 5 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 69d9e92bf..ad9e2a822 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1572,15 +1572,15 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, help_text=_(u"Related treatments when no new find is created")) cached_label = models.TextField(_(u"Cached name"), null=True, blank=True, db_index=True) - cached_periods = models.TextField( + cached_periods = models.TextField( _("Cached periods label"), blank=True, null=True, help_text=_("Generated automatically - do not edit") ) - cached_object_types = models.TextField( + cached_object_types = models.TextField( _("Cached object types label"), blank=True, null=True, help_text=_("Generated automatically - do not edit") ) - cached_materials = models.TextField( + cached_materials = models.TextField( _("Cached material types label"), blank=True, null=True, help_text=_("Generated automatically - do not edit") ) @@ -1953,6 +1953,16 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, return Find.objects.filter(pk=self.pk).values( 'cached_label')[0]['cached_label'] + def _generate_cached_periods(self): + return " & ".join([dating.period.label + for dating in self.datings.all()]) + + def _generate_cached_object_types(self): + return " & ".join([str(obj) for obj in self.object_types.all()]) + + def _generate_cached_materials(self): + return " & ".join([str(mat) for mat in self.material_types.all()]) + @classmethod def cached_label_bulk_update( cls, operation_id=None, parcel_id=None, context_record_id=None, diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 620f648fd..d5f1fdb62 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -680,7 +680,7 @@ class FindSearchTest(FindInit, TestCase): content = response.content.decode() res = json.loads(content) self.assertEqual(res['recordsTotal'], 1) - self.assertEqual(res["rows"][0]["material_types__label"], + self.assertEqual(res["rows"][0]["material_types"], str(iron_metal)) # no result for the brother @@ -744,7 +744,7 @@ class FindSearchTest(FindInit, TestCase): self.assertEqual(response.status_code, 200) res = json.loads(response.content.decode()) self.assertEqual(res['recordsTotal'], 1) - self.assertEqual(res["rows"][0]["datings__period__label"], + self.assertEqual(res["rows"][0]["cached_periods"], str(final_neo)) # no result for the brother |