Skip to content

Commit

Permalink
Merge branch 'v.3.8.x' into client_update_dependencies_v3.8.3
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	g3w-admin/client/static/client/js/app.min.js
#	g3w-admin/client/static/client/js/app.min.js.map
  • Loading branch information
wlorenzetti committed Nov 28, 2024
2 parents 8fa5eb6 + 2b84089 commit fb90b1d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 6 deletions.
12 changes: 12 additions & 0 deletions g3w-admin/core/api/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion g3w-admin/qdjango/server_filters/legend/getlegendgraphic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
31 changes: 31 additions & 0 deletions g3w-admin/qdjango/tests/test_column_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
# -------------------------------------------------

Expand Down
25 changes: 21 additions & 4 deletions g3w-admin/qdjango/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.:
<vectorjoins>
<join dynamicForm="0" targetFieldName="id" memoryCache="1" joinFieldName="N. mappa"
joinLayerId="Sommarioni_Clauzetto_5c2f9be3_2266_4760_8840_165618815314" upsertOnEdit="0"
cascadedDelete="0" editable="0"/>
<join dynamicForm="0" targetFieldName="id" memoryCache="1" joinFieldName="N_di_Mappa"
joinLayerId="Clauzetto_Sommarioni_dc968329_29b7_4f47_a79f_853c290a14cf" upsertOnEdit="0"
customPrefix="" cascadedDelete="0" hasCustomPrefix="1" editable="0"/>
</vectorjoins>
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":
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fb90b1d

Please sign in to comment.