Skip to content

Commit c84c25a

Browse files
committed
Filter unpermitted layers from visibility presets
1 parent c4e5e01 commit c84c25a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/qwc2_viewer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ def permitted_theme_item(self, item, identity, lang):
10571057

10581058
# filter by permissions
10591059
self.filter_restricted_layers(item, permitted_layers)
1060+
self.filter_visibility_presets(item, permitted_layers)
10601061
self.filter_print_templates(item, permitted_print_templates)
10611062
self.filter_edit_config(item, identity)
10621063
self.filter_item_background_layers(item, identity)
@@ -1092,6 +1093,17 @@ def filter_restricted_layers(self, layer, permitted_layers):
10921093

10931094
layer['sublayers'] = sublayers
10941095

1096+
def filter_visibility_presets(self, item, permitted_layers):
1097+
"""Filter visibility presets by permissions.
1098+
1099+
:param obj item: Theme item
1100+
:param set permitted_layers: List of permitted layers
1101+
"""
1102+
for name, entries in item.get('visibilityPresets', {}).items():
1103+
item['visibilityPresets'][name] = dict([
1104+
kv for kv in entries.items() if kv[0].split('/')[-1] in permitted_layers
1105+
])
1106+
10951107
def filter_print_templates(self, item, permitted_print_templates):
10961108
"""Filter print templates by permissions.
10971109

0 commit comments

Comments
 (0)