Skip to content

Commit

Permalink
Improve version when LWC version is EOL
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Oct 1, 2024
1 parent 85ac539 commit 24bb161
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 39 deletions.
2 changes: 1 addition & 1 deletion lizmap/definitions/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def find(cls, status_string: str):
for status in cls.__members__.values():
if str(status.value).lower() == status_string:
return status
return None
return ReleaseStatus.Unknown


@unique
Expand Down
1 change: 1 addition & 0 deletions lizmap/definitions/lizmap_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
CLOUD_ONLINE_URL = 'https://docs.lizmap.cloud'
CLOUD_ONLINE_LANGUAGES = ('en', 'fr')

# TODO Fixme, the minimum version recommended varies on the LWC version
CLOUD_QGIS_MIN_RECOMMENDED = (3, 28, 0)

UPLOAD_EXTENSIONS = ('fgb', 'gpkg', 'xlsx', 'xls', 'csv', 'ods', 'kml', 'geojson')
Expand Down
21 changes: 18 additions & 3 deletions lizmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3591,7 +3591,19 @@ def project_config_file(
target_status = ReleaseStatus.Unknown

if is_lizmap_cloud(server_metadata):
if self.dlg.current_server_info(ServerComboData.LwcBranchStatus.value) == ReleaseStatus.Retired:
eol = (ReleaseStatus.Retired, ReleaseStatus.SecurityBugfixOnly)
if self.dlg.current_server_info(ServerComboData.LwcBranchStatus.value) in eol:
if self.dlg.current_server_info(ServerComboData.LwcBranchStatus.value) == ReleaseStatus.Retired:
msg = tr(
'This version of Lizmap Web Client has now reached its <strong>end of life</strong> '
'and is not supported anymore.'
)
else:
msg = tr(
'This version of Lizmap Web Client has nearly reached its end of life as it is in '
'<strong>security bugfix mode</strong>. Only critical bugfix are added and soon the '
'branch will be declared <strong>end of life</strong>.'
)
QMessageBox.warning(
self.dlg,
CLOUD_NAME,
Expand All @@ -3603,11 +3615,14 @@ def project_config_file(
lwc_version=lwc_version.value,
)
+ "<br><br>"
+ msg
+ "<br><br>"
+ "<strong>"
+ tr(
'This version of Lizmap Web Client has now reached its end of life and is not supported '
'anymore. Please visit your administration panel in your web browser, in the dashboard, and '
'Please visit your administration panel in your web browser, in the dashboard, and '
'ask for the update.'
)
+ "</strong>"
+ "<br><br>"
+ tr(
'You might have some old project which need an update from you. The list is written on the '
Expand Down
1 change: 1 addition & 0 deletions lizmap/test/test_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ def test_release_status(self):
self.assertEqual(ReleaseStatus.SecurityBugfixOnly, ReleaseStatus.find('security_bugfix_only'))
self.assertEqual(ReleaseStatus.ReleaseCandidate, ReleaseStatus.find('feature_freeze'))
self.assertEqual(ReleaseStatus.Stable, ReleaseStatus.find('stable'))
self.assertEqual(ReleaseStatus.Unknown, ReleaseStatus.find('i_dont_know'))
36 changes: 1 addition & 35 deletions lizmap/version_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import json
import logging

from typing import Tuple

from qgis.core import Qgis, QgsNetworkContentFetcher
from qgis.PyQt.QtCore import QDate, QLocale, QUrl

Expand Down Expand Up @@ -71,38 +69,6 @@ def request_finished(self):
with open(lizmap_user_folder().joinpath("released_versions.json"), "w") as output:
output.write(content)

@classmethod
def version_status(cls, status: str) -> Tuple[ReleaseStatus, str]:
""" Return the release status according to the JSON content. """
if status == 'dev':
flag = ReleaseStatus.Dev
elif status == 'feature_freeze':
flag = ReleaseStatus.ReleaseCandidate
elif status == 'stable':
flag = ReleaseStatus.Stable
elif status == 'retired':
flag = ReleaseStatus.Retired
else:
flag = ReleaseStatus.Unknown

return flag, cls.status_display_string(flag)

@classmethod
def status_display_string(cls, status: ReleaseStatus) -> str:
""" Return a human display string status. """
if status == ReleaseStatus.Dev:
return tr('Next')
elif status == ReleaseStatus.ReleaseCandidate:
return tr('Feature freeze')
elif status == ReleaseStatus.Stable:
return tr('Stable')
elif status == ReleaseStatus.Retired:
return tr('Not maintained')
elif status is None or status == ReleaseStatus.Unknown:
return tr('Inconnu')
else:
raise Exception('Unknown status type : {}'.format(status))

def update_lwc_servers(self, released_versions: dict):
""" Update LWC version status for each server. """
for index in range(self.dialog.server_combo.count()):
Expand All @@ -120,7 +86,7 @@ def update_lwc_servers(self, released_versions: dict):
if lwc_version != version:
continue

flag, suffix = self.version_status(json_version.get('status'))
flag = ReleaseStatus.find(json_version.get('status'))
self.dialog.server_combo.setItemData(index, flag, ServerComboData.LwcBranchStatus.value)

def update_lwc_releases(self, released_versions: dict):
Expand Down

0 comments on commit 24bb161

Please sign in to comment.