From 46d12ac0e4acdb75a394dc635c9f9d6d433e3989 Mon Sep 17 00:00:00 2001 From: wlorenzetti Date: Mon, 11 Sep 2023 12:16:48 +0200 Subject: [PATCH] Fix mixing referencing and referenced fields. --- g3w-admin/core/tests/test_api.py | 3 ++- g3w-admin/qdjango/utils/data.py | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/g3w-admin/core/tests/test_api.py b/g3w-admin/core/tests/test_api.py index 84be4c798..ef4e50772 100644 --- a/g3w-admin/core/tests/test_api.py +++ b/g3w-admin/core/tests/test_api.py @@ -634,7 +634,8 @@ def testCoreInterfaceOwsView(self): self.assertEqual(len(jres['layers']), 21) self.assertEqual(jres['layers'][1]['title'], 'Acque - AdT Catasto Terreni') - self.assertEqual(len(jres['layers'][1]['crss']), 19) + print(jres['layers'][1]['crss']) + self.assertEqual(len(jres['layers'][1]['crss']), 20) def test_crs_api_rest(self): diff --git a/g3w-admin/qdjango/utils/data.py b/g3w-admin/qdjango/utils/data.py index 3061f79c9..c678ed409 100644 --- a/g3w-admin/qdjango/utils/data.py +++ b/g3w-admin/qdjango/utils/data.py @@ -1229,13 +1229,15 @@ def _getDataLayerRelations(self): 'referencingLayer': relation.referencingLayerId(), } # get only first pair relation - field_refs = [] + fields_referenging = [] + fields_referenced = [] for referencingField, referencedField in relation.fieldPairs().items(): - field_refs.append([referencingField, referencedField]) + fields_referenging.append(referencingField) + fields_referenced.append(referencedField) attrib.update({ 'fieldRef': { - 'referencingField': field_refs[0], - 'referencedField': field_refs[1] + 'referencingField': fields_referenging, + 'referencedField': fields_referenced } })