Skip to content

Commit

Permalink
Relation type many with multifield keys (#596)
Browse files Browse the repository at this point in the history
* Add case "graduatedSymbol" to getlegendgraphic filter.

* Fix relation's fields info for 1:N relation.

* Fix mixing referencing and referenced fields.

* Add case "graduatedSymbol" to getlegendgraphic filter.

* Fix check is referenced fields ar primary key.

* Fix test.

* Fix for editing with relations.

* ✨ Client:
    core: g3w-suite/g3w-client#159
    editing: g3w-suite/g3w-client-plugin-editing#53

* ✨ Client:
   core: g3w-suite/g3w-client#159

* ✨ Client:
   core: g3w-suite/g3w-client#159
   editing: g3w-suite/g3w-client-plugin-editing#53

* ✨ Client:
   editing: g3w-suite/g3w-client-plugin-editing#53

* Give to Editor Level 1 user upload geo-data grant (#594)

* Add capabilities to add files into filemanager to Editor level 1 users.

* Add sidebar menu for Editor level 1.

* Fix tests.

* RAdd testing for creations of a subdirectory inside the settings.DATASOURCE_PATH for Editor Level 1 user.

* Typo.

* Fix test typos.

---------

Co-authored-by: wlorenzetti <[email protected]>

* Fix test for external wms service.

# Conflicts:
#	g3w-admin/core/tests/test_api.py

* Fix test.

* Fix test.

---------

Co-authored-by: wlorenzetti <[email protected]>
Co-authored-by: volterra79 <[email protected]>
  • Loading branch information
3 people authored Sep 20, 2023
1 parent 18ada71 commit 9bf2557
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion g3w-admin/client/static/client/js/app.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions g3w-admin/core/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,12 +628,12 @@ def testCoreInterfaceOwsView(self):
jres = json.loads(res.content)

self.assertTrue(jres['result'])
self.assertEqual('Geoscopio_wms catasto', jres['title'])
self.assertEqual('Geoscopio_wms catasto'.lower(), jres['title'].lower())
self.assertTrue('image/png' in jres['map_formats'])
self.assertTrue('text/html' in jres['info_formats'])
self.assertEqual(len(jres['layers']), 21)

self.assertEqual(jres['layers'][1]['title'], 'Acque - AdT Catasto Terreni')
self.assertEqual(jres['layers'][1]['title'].lower(), 'Acque - AdT Catasto Terreni'.lower())
self.assertEqual(len(jres['layers'][1]['crss']), 20)


Expand Down
5 changes: 3 additions & 2 deletions g3w-admin/editing/api/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ def save_vector_data(self, metadata_layer, post_layer_data, has_transactions, po
# case relation data ADD, if father referenced field is pk
if is_referenced_field_is_pk:
for newid in kwargs['referenced_layer_insert_ids']:
if geojson_feature['properties'][metadata_layer.referencing_field] == newid['clientid']:
geojson_feature['properties'][metadata_layer.referencing_field] = newid['id']
for referencing_field in metadata_layer.referencing_field:
if geojson_feature['properties'][referencing_field] == newid['clientid']:
geojson_feature['properties'][referencing_field] = newid['id']

if mode_editing == EDITING_POST_DATA_UPDATED:
# control feature locked
Expand Down
2 changes: 1 addition & 1 deletion g3w-admin/editing/static/editing/js/plugin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion g3w-admin/qdjango/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_qgis_project(self):

# check layerRelations
# ------------------------------------------
layer_relations_to_check = '[{"referencingLayer": "cities10000eu20171228095720113", "strength": "Association", "referencedLayer": "countries_simpl20171228095706310", "name": "countries-citites", "id": "cities1000_ISO2_CODE_countries__ISOCODE", "fieldRef": {"referencingField": "ISO2_CODE", "referencedField": "ISOCODE"}}]'
layer_relations_to_check = '[{"referencingLayer": "cities10000eu20171228095720113", "strength": "Association", "referencedLayer": "countries_simpl20171228095706310", "name": "countries-citites", "id": "cities1000_ISO2_CODE_countries__ISOCODE", "fieldRef": {"referencingField": ["ISO2_CODE"], "referencedField": ["ISOCODE"]}}]'
self.assertEqual(self.project.layerRelations,
json.loads(layer_relations_to_check))

Expand Down
10 changes: 6 additions & 4 deletions g3w-admin/qdjango/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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][0],
'referencedField': field_refs[0][1]
'referencingField': fields_referenging,
'referencedField': fields_referenced
}
})

Expand Down
2 changes: 1 addition & 1 deletion g3w-admin/qdjango/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def set_metadata_relations(self, request, **kwargs):
# qgis_layer is the referenced layer
qgis_layer = self.layer.qgis_layer
referenced_field_is_pk = [qgis_layer.fields().indexFromName(
relation['fieldRef']['referencedField'])] == qgis_layer.primaryKeyAttributes()
rf) for rf in relation['fieldRef']['referencedField']] == qgis_layer.primaryKeyAttributes()

# It's an old and buggy QGIS version so we cannot trust primaryKeyAttributes() and we go guessing
if IS_QGIS_3_10:
Expand Down

0 comments on commit 9bf2557

Please sign in to comment.