diff options
-rw-r--r-- | archaeological_context_records/models.py | 37 | ||||
-rw-r--r-- | archaeological_operations/tests.py | 1 |
2 files changed, 21 insertions, 17 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index c45cb1fd4..1ec32ea83 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -290,30 +290,33 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms, sql = """ UPDATE "archaeological_context_records_contextrecord" AS cr SET cached_label = - CASE context_records_cached_label_bulk_update.main_code - WHEN NULL THEN - CASE context_records_cached_label_bulk_update.year - IS NOT NULL - AND context_records_cached_label_bulk_update.ope_code - IS NOT NULL - WHEN TRUE THEN - '{ope_prefix}' || - context_records_cached_label_bulk_update.year || - '-' || - context_records_cached_label_bulk_update.ope_code - ELSE '' - END - ELSE - '{main_ope_prefix}' || - context_records_cached_label_bulk_update.main_code + CASE + WHEN context_records_cached_label_bulk_update.main_code + IS NULL + THEN + CASE + WHEN context_records_cached_label_bulk_update.year + IS NOT NULL + AND context_records_cached_label_bulk_update.ope_code + IS NOT NULL + THEN + '{ope_prefix}' || + context_records_cached_label_bulk_update.year || + '-' || + context_records_cached_label_bulk_update.ope_code + ELSE '' END + ELSE + '{main_ope_prefix}' || + context_records_cached_label_bulk_update.main_code + END || '{join}' || context_records_cached_label_bulk_update.section || '{join}' || context_records_cached_label_bulk_update.number || '{join}' || context_records_cached_label_bulk_update.label FROM context_records_cached_label_bulk_update WHERE cr.id = context_records_cached_label_bulk_update.id - AND cr.id IN ( + AND cr.id IN ( SELECT id FROM archaeological_context_records_contextrecord WHERE {where} ); diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index ab485572a..25f278880 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -806,6 +806,7 @@ class OperationTest(TestCase, OperationInitTest): self.assertEqual(ope_id, '{}2011-1'.format( settings.ISHTAR_DEF_OPE_PREFIX)) + operation = models.Operation.objects.get(pk=operation.pk) operation.code_patriarche = '666' operation.save() cr = ContextRecord.objects.get(pk=cr.pk) |