Skip to content

Commit

Permalink
Checks - Add QGIS server version check in the table
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Dec 21, 2023
1 parent 0eef68b commit a8ada2a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lizmap/dialogs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def follow_map_theme_toggled(self):
if current_text.endswith(text):
self.combo_legend_option.setCurrentText(current_text.replace(text, ''))

def check_qgis_version(self, message_bar=False, widget=False):
def check_qgis_version(self, message_bar=False, widget=False) -> bool:
""" Compare QGIS desktop and server versions and display results if necessary. """
self.warning_old_server.setVisible(False)

Expand All @@ -567,11 +567,11 @@ def check_qgis_version(self, message_bar=False, widget=False):
qgis_server = (int(qgis_server[0]), int(qgis_server[1]))
except AttributeError:
# Maybe returning LWC 3.4 or LWC 3.5 without the server plugin
return
return False

if qgis_server >= qgis_desktop:
# Alright
return
return False

title = tr('QGIS server version is lower than QGIS desktop version')
LOGGER.error(title)
Expand Down Expand Up @@ -605,6 +605,8 @@ def check_qgis_version(self, message_bar=False, widget=False):
).format(qgis_server, qgis_desktop)
self.warning_old_server.set_text(message)

return True

def current_server_info(self, info: ServerComboData):
""" Return the current LWC server information from the server combobox. """
return self.server_combo.currentData(info)
Expand Down
4 changes: 3 additions & 1 deletion lizmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3176,6 +3176,9 @@ def project_config_file(
Error(Path(self.project.fileName()).name, checks.EmptyBaseLayersGroup)
)

if self.dlg.check_qgis_version(message_bar=True):
self.dlg.check_results.add_error(Error(tr('Global'), checks.ServerVersion))

# Not blocking, we change it in the background
if self.project.readNumEntry("WMSMaxAtlasFeatures", '')[0] <= 0:
LOGGER.info("The maximum atlas features was less than '1'. We set it to '1' to at least have a value.")
Expand Down Expand Up @@ -3890,7 +3893,6 @@ def save_cfg_file(
variables['lizmap_repository'] = self.dlg.current_repository()
self.project.setCustomVariables(variables)

self.dlg.check_qgis_version(message_bar=True)
if not lwc_version:
lwc_version = self.current_lwc_version()

Expand Down
3 changes: 3 additions & 0 deletions lizmap/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def current_git_hash() -> str:
hash_number = git_show.communicate()[0].partition('\n')[0]
except IndexError:
# Reported on redmine
# Was-it due to Python 3.7.0 ?
# IndexError: list index out of range
hash_number = ''

Expand All @@ -179,6 +180,7 @@ def has_git() -> bool:
output = git_show.communicate()[0].partition('\n')[0]
except IndexError:
# Reported on redmine
# Was-it due to Python 3.7.0 ?
# IndexError: list index out of range
output = ''

Expand All @@ -201,6 +203,7 @@ def next_git_tag():
tag = git_show.communicate()[0].partition('\n')[0]
except IndexError:
# Reported on redmine
# Was-it due to Python 3.7.0 ?
# IndexError: list index out of range
tag = ''

Expand Down
33 changes: 33 additions & 0 deletions lizmap/widgets/check_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,39 @@ def __init__(self):
Severities().low,
QIcon(':/images/themes/default/mIconWms.svg'),
)
self.ServerVersion = Check(
'old_qgis_server_version',
tr('QGIS server version is lower than QGIS desktop version'),
tr(
"QGIS desktop is writing QGS project file in the future compare to QGIS server. QGIS server might not "
"be able to read the file correctly. Versions between desktop and server must be equal, or QGIS server "
"can have a newer version."
),
(
'<ul>'
'<li>{upgrade}</li>'
'<li>{downgrade}</li>'
'</ul>'
).format(
upgrade=tr("Either upgrade your QGIS Server"),
downgrade=tr("Or downgrade your QGIS Desktop"),
),
Levels.GlobalConfig,
Severities().important,
QIcon(':/images/icons/qgis_icon.svg'),
(
'<ul>'
'<li>{upgrade}</li>'
'<li>{downgrade}</li>'
'</ul>'
).format(
upgrade=tr(
"Either check if an upgrade of QGIS server is available in Lizmap Web Client, in the "
"administration panel. Current LTR versions should be available."
),
downgrade=tr("Or downgrade your QGIS Desktop"),
),
)
self.PkInt8 = Check(
'primary_key_bigint',
tr('Invalid bigint (integer8) field for QGIS Server as primary key'),
Expand Down

0 comments on commit a8ada2a

Please sign in to comment.