Skip to content

Commit

Permalink
Merge pull request #582 from Gustry/ogc-validity
Browse files Browse the repository at this point in the history
Move the OGC make project valid up in the process
  • Loading branch information
Gustry authored May 30, 2024
2 parents 85b7848 + cdfd84a commit 28f0e35
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
3 changes: 1 addition & 2 deletions lizmap/ogc_project_validity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 20 additions & 19 deletions lizmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 28f0e35

Please sign in to comment.