Skip to content

Commit

Permalink
Merge pull request #603 from Gustry/qgis-3-22
Browse files Browse the repository at this point in the history
Raise QGIS minimum version to 3.22
  • Loading branch information
Gustry authored Sep 16, 2024
2 parents 39b889b + 27d5dc5 commit a4b8e67
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 171 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
architecture: x64
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
Expand All @@ -46,11 +46,10 @@ jobs:
strategy:
matrix:
qgis_version: [
# "latest",
"release-3_34",
"release-3_28",
"release-3_22",
"release-3_16",
# "latest",
]
steps:

Expand Down Expand Up @@ -80,10 +79,10 @@ jobs:

- uses: actions/checkout@v4

- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
cache: "pip"
cache-dependency-path: "requirements/packaging.txt"

Expand Down Expand Up @@ -115,15 +114,6 @@ jobs:
--osgeo-password ${{ secrets.OSGEO_PASSWORD }}
--create-plugin-repo
- name: Tweet
uses: mugi111/[email protected]
with:
consumer_key: ${{ secrets.TWITTER_CONSUMER_KEY }}
consumer_secret: ${{ secrets.TWITTER_CONSUMER_SECRET }}
access_token_key: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
access_token_secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
tweet_body: "New version of @LizmapForQgis desktop plugin ${{ env.RELEASE_VERSION }} 🦎 on #QGIS https://github.com/3liz/lizmap-plugin/releases"

- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: check-added-large-files

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: 6.1.0
hooks:
- id: flake8
exclude: lizmap/lizmap_api/
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

* Raise QGIS minimum version to 3.22

## 4.3.24 - 2024-09-09

* Improve download of QGS project
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL:=bash
.ONESHELL:
.PHONY: env

QGIS_VERSION ?= release-3_16
QGIS_VERSION ?= release-3_22

start_tests:
@echo 'Start docker compose'
Expand Down
6 changes: 2 additions & 4 deletions lizmap/dialogs/dock_html_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from lizmap.toolbelt.i18n import tr
from lizmap.toolbelt.resources import resources_path
from lizmap.toolbelt.version import qgis_version

try:
from qgis.PyQt.QtWebKitWidgets import QWebView
Expand Down Expand Up @@ -104,9 +103,8 @@ def __init__(self, parent, *__args):
self.feature.featureChanged.connect(self.update_html)
self.feature.setShowBrowserButtons(True)

if qgis_version() >= 32000:
# We don't have a better signal to listen to
QgsProject.instance().dirtySet.connect(self.update_html)
# We don't have a better signal to listen to
QgsProject.instance().dirtySet.connect(self.update_html)

self.update_html()

Expand Down
15 changes: 1 addition & 14 deletions lizmap/dialogs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ def __init__(self, parent=None, is_dev_version=True, lwc_version: LwcVersions =
self.label_lizmap_logo.setPixmap(pixmap)

# Initial extent widget
if qgis_version() >= 31800:
self.widget_initial_extent.setMapCanvas(iface.mapCanvas(), False)
else:
self.widget_initial_extent.setMapCanvas(iface.mapCanvas())
self.widget_initial_extent.setMapCanvas(iface.mapCanvas(), False)
self.widget_initial_extent.setOutputCrs(self.project.crs())
self.widget_initial_extent.setOriginalExtent(iface.mapCanvas().extent(), self.project.crs())
self.project.crsChanged.connect(self.project_crs_changed)
Expand Down Expand Up @@ -544,20 +541,10 @@ def has_auto_fix(self) -> bool:

def enabled_ssl_button(self, status: bool):
""" Enable or not the button. """
if Qgis.QGIS_VERSION_INT <= 32200:
self.button_convert_ssl.setToolTip(tr("QGIS 3.22 minimum is required"))
self.button_convert_ssl.setEnabled(False)
return

self.button_convert_ssl.setEnabled(status)

def enabled_estimated_md_button(self, status: bool):
""" Enable or not the button. """
if Qgis.QGIS_VERSION_INT <= 32200:
self.button_use_estimated_md.setToolTip(tr("QGIS 3.22 minimum is required"))
self.button_use_estimated_md.setEnabled(False)
return

self.button_use_estimated_md.setEnabled(status)

def enabled_trust_project(self, status: bool):
Expand Down
25 changes: 8 additions & 17 deletions lizmap/dialogs/server_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,10 @@
from lizmap.definitions.qgis_settings import Settings
from lizmap.logger import log_function
from lizmap.saas import is_lizmap_cloud, webdav_properties
from lizmap.server_dav import WebDav
from lizmap.toolbelt.i18n import tr
from lizmap.toolbelt.version import qgis_version, version

if qgis_version() >= 32200:
from lizmap.server_dav import WebDav

from lizmap.toolbelt.plugin import lizmap_user_folder, user_settings
from lizmap.toolbelt.version import version

LOGGER = logging.getLogger('Lizmap')
THUMBS = " 👍"
Expand Down Expand Up @@ -945,11 +942,7 @@ def save_auth_id(self) -> bool:
LOGGER.debug("Edit current information authentication ID : {}".format(self.auth_id))
# Edit
config.setId(self.auth_id)
if qgis_version() < 32000:
auth_manager.removeAuthenticationConfig(self.auth_id)
result = auth_manager.storeAuthenticationConfig(config)
else:
result = auth_manager.storeAuthenticationConfig(config, True)
result = auth_manager.storeAuthenticationConfig(config, True)
# The JSON will be saved later, in the table
else:
# Creation
Expand Down Expand Up @@ -1120,15 +1113,13 @@ def request_check_url(self, url: str, login: str, password: str) -> Tuple[bool,
if any(item in version() for item in UNSTABLE_VERSION_PREFIX):
# Debug for devs
self.has_repository = False
if qgis_version() < 32200:
# Missing PyQGIS class for managing webdav

dav_metadata = webdav_properties(content)
if not dav_metadata:
self.dav_url = None
else:
dav_metadata = webdav_properties(content)
if not dav_metadata:
self.dav_url = None
else:
self.dav_url = self.trailing_slash(dav_metadata.get('url')) + dav_metadata.get('projects_path')
self.dav_url = self.trailing_slash(dav_metadata.get('url')) + dav_metadata.get('projects_path')

return True, '', True

def _uri(self) -> QgsDataSourceUri:
Expand Down
2 changes: 1 addition & 1 deletion lizmap/metadata.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[general]
name=Lizmap
qgisMinimumVersion=3.16
qgisMinimumVersion=3.22
qgisMaximumVersion=3.99
author=3Liz
[email protected]
Expand Down
67 changes: 29 additions & 38 deletions lizmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
QgsEditFormConfig,
QgsExpression,
QgsFileDownloader,
QgsIconUtils,
QgsLayerTree,
QgsLayerTreeGroup,
QgsMapLayer,
Expand All @@ -38,17 +39,9 @@
QgsWkbTypes,
)
from qgis.gui import QgsFileWidget
from qgis.PyQt.QtCore import QEventLoop
from qgis.PyQt.QtWidgets import QApplication, QFileDialog

from lizmap.dialogs.news import NewConfigDialog
from lizmap.dialogs.server_wizard import CreateFolderWizard

if Qgis.QGIS_VERSION_INT >= 32200:
from qgis.core import QgsIconUtils

from qgis.PyQt.QtCore import (
QCoreApplication,
QEventLoop,
QStorageInfo,
Qt,
QTranslator,
Expand All @@ -66,7 +59,9 @@
)
from qgis.PyQt.QtWidgets import (
QAction,
QApplication,
QDialogButtonBox,
QFileDialog,
QLineEdit,
QMessageBox,
QPushButton,
Expand Down Expand Up @@ -127,6 +122,8 @@
from lizmap.dialogs.html_maptip import HtmlMapTipDialog
from lizmap.dialogs.lizmap_popup import LizmapPopupDialog
from lizmap.dialogs.main import LizmapDialog
from lizmap.dialogs.news import NewConfigDialog
from lizmap.dialogs.server_wizard import CreateFolderWizard
from lizmap.dialogs.wizard_group import WizardGroupDialog
from lizmap.drag_drop_dataviz_manager import DragDropDatavizManager
from lizmap.forms.atlas_edition import AtlasEditionDialog
Expand Down Expand Up @@ -185,6 +182,7 @@
from qgis.core import QgsProjectServerValidator

from lizmap.qt_style_sheets import NEW_FEATURE_COLOR, NEW_FEATURE_CSS
from lizmap.server_dav import WebDav
from lizmap.server_lwc import MAX_DAYS, ServerManager
from lizmap.toolbelt.convert import to_bool
from lizmap.toolbelt.custom_logging import (
Expand Down Expand Up @@ -212,9 +210,6 @@
from lizmap.tooltip import Tooltip
from lizmap.version_checker import VersionChecker

if qgis_version() >= 32200:
from lizmap.server_dav import WebDav

LOGGER = logging.getLogger(plugin_name())
VERSION_URL = 'https://raw.githubusercontent.com/3liz/lizmap-web-client/versions/versions.json'
# To try a local file
Expand Down Expand Up @@ -301,12 +296,9 @@ def __init__(self, iface, lwc_version: LwcVersions = None):
self.is_dev_version = any(item in self.version for item in UNSTABLE_VERSION_PREFIX)
self.dlg = LizmapDialog(is_dev_version=self.is_dev_version, lwc_version=self._version)

if Qgis.QGIS_VERSION_INT >= 32200:
self.webdav = WebDav()
# Give the dialog only the first time
self.webdav.setup_webdav_dialog(self.dlg)
else:
self.webdav = None
self.webdav = WebDav()
# Give the dialog only the first time
self.webdav.setup_webdav_dialog(self.dlg)
# self.check_webdav()

self.dock_html_preview = None
Expand Down Expand Up @@ -1501,27 +1493,26 @@ def initGui(self):
"This value will be replaced on the server side when evaluating the expression thanks to "
"the QGIS server Lizmap plugin.")
# Register variable helps
if qgis_version() >= 32200:
QgsExpression.addVariableHelpText(
"lizmap_user",
"{}<br/><br/>{}<br/><br/>{}".format(
tr("The current Lizmap login as a string."),
tr("It might be an empty string if the user is not connected."),
server_side,
)
QgsExpression.addVariableHelpText(
"lizmap_user",
"{}<br/><br/>{}<br/><br/>{}".format(
tr("The current Lizmap login as a string."),
tr("It might be an empty string if the user is not connected."),
server_side,
)
QgsExpression.addVariableHelpText(
"lizmap_user_groups",
"{}<br/><br/>{}<br/><br/>{}<br/><br/>{}".format(
tr("The current groups of the logged user as an <strong>array</strong>."),
tr("It might be an empty array if the user is not connected."),
tr(
"You might need to use functions in the <strong>Array</strong> expression category, such as "
"<pre>array_to_string</pre> to convert it to a string."),
server_side,
)
)
QgsExpression.addVariableHelpText(
"lizmap_user_groups",
"{}<br/><br/>{}<br/><br/>{}<br/><br/>{}".format(
tr("The current groups of the logged user as an <strong>array</strong>."),
tr("It might be an empty array if the user is not connected."),
tr(
"You might need to use functions in the <strong>Array</strong> expression category, such as "
"<pre>array_to_string</pre> to convert it to a string."),
server_side,
)
QgsExpression.addVariableHelpText("lizmap_repository", tr("The current repository ID on the server."))
)
QgsExpression.addVariableHelpText("lizmap_repository", tr("The current repository ID on the server."))

# Let's fix the dialog to the first panel
self.dlg.mOptionsListWidget.setCurrentRow(Panels.Information)
Expand Down Expand Up @@ -3401,7 +3392,7 @@ def check_project(

# Icon
for k, v in filters.items():
if k == "_wkb_type" and Qgis.QGIS_VERSION_INT >= 32000:
if k == "_wkb_type":
icon = QgsIconUtils.iconForWkbType(v)
break
else:
Expand Down
7 changes: 1 addition & 6 deletions lizmap/server_lwc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,12 +1279,7 @@ def migrate_password_manager(self, servers: list):
config.setConfig('username', user)
config.setConfig('password', password)
config.setConfig('realm', QUrl(url).host())

if qgis_version() < 32000:
auth_manager.removeAuthenticationConfig(auth_id)
result = auth_manager.storeAuthenticationConfig(config)
else:
result = auth_manager.storeAuthenticationConfig(config, True)
result = auth_manager.storeAuthenticationConfig(config, True)

if not result:
LOGGER.critical("Error while migrating the server")
Expand Down
30 changes: 7 additions & 23 deletions lizmap/test/test_dialog_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from lizmap.forms.time_manager_edition import TimeManagerEditionDialog
from lizmap.forms.tooltip_edition import ToolTipEditionDialog
from lizmap.toolbelt.resources import plugin_test_data_path
from lizmap.toolbelt.version import qgis_version

__copyright__ = 'Copyright 2023, 3Liz'
__license__ = 'GPL version 3'
Expand Down Expand Up @@ -61,11 +60,7 @@ def test_load_save_collection_dataviz(self):
"""Test we can load collection."""
dialog = DatavizEditionDialog()
self.assertFalse(dialog.error.isVisible())
if qgis_version() < 32200:
self.assertEqual('', dialog.x_field.currentField())
self.assertEqual(dialog.validate(), 'The field "x field" is mandatory.')
else:
self.assertEqual('id', dialog.x_field.currentField())
self.assertEqual('id', dialog.x_field.currentField())

data = [
{
Expand All @@ -92,15 +87,7 @@ def test_atlas_dialog(self):
dialog = AtlasEditionDialog()
self.assertFalse(dialog.error.isVisible())

if qgis_version() >= 32200:
self.assertEqual(dialog.primary_key.currentField(), 'id')
else:
self.assertEqual(dialog.validate(), 'The field "primary key" is mandatory.')
dialog.primary_key.setCurrentIndex(1)
self.assertEqual(dialog.validate(), 'The field "feature label" is mandatory.')
dialog.feature_label.setCurrentIndex(1)
self.assertEqual(dialog.validate(), 'The field "sort field" is mandatory.')
dialog.sort_field.setCurrentIndex(1)
self.assertEqual(dialog.primary_key.currentField(), 'id')

self.assertEqual(
'The layers you have chosen for this tool must be checked in the "WFS Capabilities"\n option of the QGIS '
Expand All @@ -126,14 +113,11 @@ def test_atlas_dialog(self):

del dialog
dialog = AtlasEditionDialog()
if qgis_version() < 32200:
self.assertEqual(dialog.validate(), 'The field "primary key" is mandatory.')
else:
self.assertEqual(
dialog.validate(),
'The layers you have chosen for this tool must be checked in the "WFS Capabilities"\n option of the '
'QGIS Server tab in the "Project Properties" dialog.'
)
self.assertEqual(
dialog.validate(),
'The layers you have chosen for this tool must be checked in the "WFS Capabilities"\n option of the '
'QGIS Server tab in the "Project Properties" dialog.'
)

dialog.load_form(data)

Expand Down
Loading

0 comments on commit a4b8e67

Please sign in to comment.