Skip to content

Commit f3e7a2d

Browse files
committed
Allow specifying printTemplateBlacklist in theme item configuration to omit print templates
1 parent 718df10 commit f3e7a2d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/config_generator/qgs_reader.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def read(self, map_prefix, theme_item, edit_datasets):
148148

149149
return {
150150
"project_crs": self.__project_crs(root),
151-
"print_templates": self.__print_templates(root, shortname_map),
151+
"print_templates": self.__print_templates(root, shortname_map, theme_item),
152152
"visibility_presets": self.__visibility_presets(root),
153153
"layer_metadata": self.__layer_metadata(root, shortname_map, map_prefix, edit_datasets, theme_item, qgs_dir),
154154
}
@@ -159,14 +159,15 @@ def __project_crs(self, root):
159159
authid = root.find('./projectCrs/spatialrefsys/authid')
160160
return authid.text if authid is not None else None
161161

162-
def __print_templates(self, root, shortname_map):
162+
def __print_templates(self, root, shortname_map, theme_item):
163163
""" Collect print templates from QGS and merge with global print layouts. """
164164

165+
printTemplateBlacklist = theme_item.get("printTemplateBlacklist", [])
165166
restrictedLayouts = [el.text for el in root.findall('./properties/WMSRestrictedComposers/value')]
166167
print_templates = []
167168
composer_template_map = {}
168169
for template in root.findall('.//Layout'):
169-
if not template.get('name') in restrictedLayouts:
170+
if template.get('name') not in restrictedLayouts and template.get('name') not in printTemplateBlacklist:
170171
composer_template_map[template.get('name')] = template
171172

172173
for template in composer_template_map.values():
@@ -229,7 +230,7 @@ def __print_templates(self, root, shortname_map):
229230
project_template_titles = [template['title'] for template in print_templates]
230231
return print_templates + [
231232
template for template in self.global_print_layouts
232-
if template["title"] not in project_template_titles
233+
if template["title"] not in project_template_titles and template["title"] not in printTemplateBlacklist
233234
]
234235

235236

0 commit comments

Comments
 (0)