From 47e4d89020f220ede4d23e1322cd859f421082ff Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 30 May 2024 12:19:13 +0200 Subject: [PATCH 1/2] Move the OGC make project valid up in the process --- lizmap/plugin.py | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lizmap/plugin.py b/lizmap/plugin.py index d4dd9890..9b76b9e4 100755 --- a/lizmap/plugin.py +++ b/lizmap/plugin.py @@ -3497,6 +3497,26 @@ def project_config_file( self, lwc_version: LwcVersions, with_gui: bool = True, check_server=True, ignore_error=False ) -> Optional[Dict]: """ Get the JSON CFG content. """ + + if lwc_version >= LwcVersions.Lizmap_3_6: + LOGGER.info( + 'Lizmap Web Client target version {}, let\'s try to make the project valid.'.format( + lwc_version.value) + ) + # Set shortnames if it's not set + ogc_projet_validity = OgcProjectValidity(self.project) + ogc_projet_validity.add_shortnames() + ogc_projet_validity.set_project_short_name() + + validator = QgsProjectServerValidator() + valid, results = validator.validate(self.project) + LOGGER.info(f"Project has been detected : {'VALID' if valid else 'NOT valid'} according to OGC validation.") + else: + LOGGER.info( + "Lizmap Web Client target version {}, we do not update the project for OGC validity.".format( + lwc_version.value) + ) + if not self.check_project(lwc_version, with_gui, check_server, ignore_error): # Some blocking issues, we can not continue return None @@ -4319,25 +4339,6 @@ def save_cfg_file( ), QMessageBox.Ok) return False - if lwc_version >= LwcVersions.Lizmap_3_6: - LOGGER.info( - 'Lizmap Web Client target version {}, let\'s try to make the project valid.'.format( - lwc_version.value) - ) - # Set shortnames if it's not set - ogc_projet_validity = OgcProjectValidity(self.project) - ogc_projet_validity.add_shortnames() - ogc_projet_validity.set_project_short_name() - - validator = QgsProjectServerValidator() - valid, results = validator.validate(self.project) - LOGGER.info(f"Project has been detected : {'VALID' if valid else 'NOT valid'} according to OGC validation.") - else: - LOGGER.info( - "Lizmap Web Client target version {}, we do not update the project for OGC validity.".format( - lwc_version.value) - ) - # global project option checking is_valid, message = self.check_global_project_options() if not is_valid: From cdfd84a025cf06c1f9f2e7f2fc027906528f739d Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 30 May 2024 16:43:33 +0200 Subject: [PATCH 2/2] Fix adding automatic shortname for the project --- lizmap/ogc_project_validity.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lizmap/ogc_project_validity.py b/lizmap/ogc_project_validity.py index 53c4edd9..bf931211 100644 --- a/lizmap/ogc_project_validity.py +++ b/lizmap/ogc_project_validity.py @@ -95,8 +95,7 @@ def _read_all_shortnames(self, group: QgsLayerTreeNode, existing_shortnames: Lis def set_project_short_name(self): """ Check and set the project short name. """ # Inspired by QgsProjectServerValidator::validate() - existing = self.existing_shortnames() - + existing, _ = self.existing_shortnames() root_layer_name = self.project.readEntry("WMSRootName", "/", "")[0] if not root_layer_name and self.project.title(): # If short name is not defined, we take the project title