diff --git a/g3w-admin/core/api/base/views.py b/g3w-admin/core/api/base/views.py index 3f2194717..d779c7b34 100644 --- a/g3w-admin/core/api/base/views.py +++ b/g3w-admin/core/api/base/views.py @@ -428,6 +428,18 @@ def response_config_mode(self, request): 'fields': fields, } + # Filter fields by user + if self.request.user: + visiblefields = self.layer.visible_fields_for_user(self.request.user) + if len(visiblefields) != len(vector_params['fields']): + newfields = [] + for f in vector_params['fields']: + if f['name'] in visiblefields: + newfields.append(f) + + if newfields: + vector_params['fields'] = newfields + # post_create_maplayerattributes signal post_create_maplayerattributes.send( self, layer=self.layer, vector_params=vector_params) diff --git a/g3w-admin/qdjango/server_filters/legend/getlegendgraphic.py b/g3w-admin/qdjango/server_filters/legend/getlegendgraphic.py index bff39970b..888bd498e 100644 --- a/g3w-admin/qdjango/server_filters/legend/getlegendgraphic.py +++ b/g3w-admin/qdjango/server_filters/legend/getlegendgraphic.py @@ -72,7 +72,15 @@ def responseComplete(self): renderer = layer.renderer() - if renderer.type() in ("categorizedSymbol", "ruleBased", "graduatedSymbol","graduatedSymbol"): + renderer_types = ( + "categorizedSymbol", + "ruleBased", + "graduatedSymbol", + "graduatedSymbol", + "RuleRenderer" + ) + + if renderer.type() in renderer_types: body = handler.body() json_data = json.loads(bytes(body)) categories = {item.label(): {'ruleKey': item.ruleKey(), 'checked': renderer.legendSymbolItemChecked( diff --git a/g3w-admin/qdjango/tests/test_column_acl.py b/g3w-admin/qdjango/tests/test_column_acl.py index 315269ee3..d4a5c6cad 100644 --- a/g3w-admin/qdjango/tests/test_column_acl.py +++ b/g3w-admin/qdjango/tests/test_column_acl.py @@ -288,6 +288,22 @@ def test_vector_api(self): self.assertIsNotNone(record['AREA']) self.assertIsNotNone(record['SOURCETHM']) + # Test for /api/vector/config + response = self._testApiCallAdmin01( + 'core-vector-api', [ + 'config', + 'qdjango', + self.world.project.pk, + self.world.qgis_layer.id()]) + + resp = json.loads(response.content) + + fields = [f['name'] for f in resp['vector']['fields']] + + self.assertTrue('AREA' in fields) + self.assertTrue('SOURCETHM' in fields) + + acl = ColumnAcl(layer=self.world, user=self.test_user1, restricted_fields=['AREA', 'SOURCETHM']) acl.save() @@ -306,6 +322,21 @@ def test_vector_api(self): self.assertIsNone(record['AREA']) self.assertIsNone(record['SOURCETHM']) + # Test for /api/vector/config + response = self._testApiCallAdmin01( + 'core-vector-api', [ + 'config', + 'qdjango', + self.world.project.pk, + self.world.qgis_layer.id()]) + + resp = json.loads(response.content) + + fields = [f['name'] for f in resp['vector']['fields']] + + self.assertFalse('AREA' in fields) + self.assertFalse('SOURCETHM' in fields) + # Test for download API # ------------------------------------------------- diff --git a/g3w-admin/qdjango/utils/data.py b/g3w-admin/qdjango/utils/data.py index 1b447a963..e481ed2a8 100644 --- a/g3w-admin/qdjango/utils/data.py +++ b/g3w-admin/qdjango/utils/data.py @@ -332,7 +332,7 @@ def _getDataLayerType(self): if self.qgs_layer.type() == QgsMapLayerType.VectorTileLayer: layer_type = 'vector-tile' - if layer_type == 'arcgisvectortilelayer': + if layer_type == 'arcgisvectortileservice': layer_type = 'vector-tile' if not layer_type in availableTypes: @@ -388,11 +388,28 @@ def _getDataVectorjoins(self): # get root of layer-tree-group ret = [] + try: vectorjoins = self.qgs_layer.vectorJoins() + except: + vectorjoins = [] - for order, join in enumerate(vectorjoins): + for order, join in enumerate(vectorjoins): + try: + ''' + Sometimes the the vectorjoins layer section ina QGIS project can contains old 'ghost' joins, i.e.: + + + + + The layer Sommarioni_Clauzetto_5c2f9be3_2266_4760_8840_165618815314 is not present inside the project, + may be it is a old layer removed from the project. + ''' # Prefix management if layer_tree_vectorjoins[order].get("hasCustomPrefix") == "1": @@ -418,8 +435,8 @@ def _getDataVectorjoins(self): # For join 1to1 self.qgisProject.relation_1to1_layers.append(self.layerId) - except: - pass + except: + pass return ret def _getDataCapabilities(self): diff --git a/requirements.txt b/requirements.txt index 45374a268..2ab928343 100644 --- a/requirements.txt +++ b/requirements.txt @@ -38,5 +38,5 @@ django-redis==5.2.0 django-registration==3.4 django-recaptcha==3.0.0 pydantic==2.6.3 -weasyprint==60.2 +weasyprint==63.0 distro==1.7.0