From a161c9c32c5f4101a0e32326e7c670801a09cdd5 Mon Sep 17 00:00:00 2001 From: signedav Date: Fri, 1 Dec 2023 12:56:03 +0100 Subject: [PATCH 1/2] set transaction mode as enum --- .../workflow_wizard/project_creation_page.py | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/QgisModelBaker/gui/workflow_wizard/project_creation_page.py b/QgisModelBaker/gui/workflow_wizard/project_creation_page.py index a1d3d7fb3..804ad82f5 100644 --- a/QgisModelBaker/gui/workflow_wizard/project_creation_page.py +++ b/QgisModelBaker/gui/workflow_wizard/project_creation_page.py @@ -277,11 +277,34 @@ def _create_project(self): self.progress_bar.setValue(55) - # on geopackages we don't use the transaction mode on default, since this leaded to troubles, except the topping sais so + transaction_mode = custom_project_properties.get("transaction_mode", None) + + if Qgis.QGIS_VERSION_INT < 32600: + # pass transaction_mode as boolean + if transaction_mode is None: + # on geopackages we don't use the transaction mode on default otherwise we do + transaction_mode = not bool(self.configuration.tool & DbIliMode.gpkg) + else: + transaction_mode = custom_transaction_mode == "AutomaticGroups" + else: + # pass transaction_mode as string + if transaction_mode is None: + # on geopackages we don't use the transaction mode on default otherwise we do + transaction_mode = ( + "Disabled" + if not bool(self.configuration.tool & DbIliMode.gpkg) + else "AutomaticGroups" + ) + else: + # in case the topping used True/False value we need to convert + if transaction_mode is True: + transaction_mode = "AutomaticGroups" + if transaction_mode is False: + transaction_mode = "Disabled" + # otherwise it's already a string and could be everything + project = Project( - auto_transaction=not bool(self.configuration.tool & DbIliMode.gpkg) - or custom_project_properties.get("transaction_mode", "") - == "AutomaticGroups", + auto_transaction=transaction_mode, context={"catalogue_datasetname": CATALOGUE_DATASETNAME}, optimize_strategy=self.optimize_combo.currentData(), ) From ce00dfb5ff85a72d7e632bb7bbe44d8fbc1960e7 Mon Sep 17 00:00:00 2001 From: signedav Date: Fri, 1 Dec 2023 14:19:28 +0100 Subject: [PATCH 2/2] use enumvalues for static string values --- .../gui/workflow_wizard/project_creation_page.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/QgisModelBaker/gui/workflow_wizard/project_creation_page.py b/QgisModelBaker/gui/workflow_wizard/project_creation_page.py index 804ad82f5..dd4a7039a 100644 --- a/QgisModelBaker/gui/workflow_wizard/project_creation_page.py +++ b/QgisModelBaker/gui/workflow_wizard/project_creation_page.py @@ -285,7 +285,9 @@ def _create_project(self): # on geopackages we don't use the transaction mode on default otherwise we do transaction_mode = not bool(self.configuration.tool & DbIliMode.gpkg) else: - transaction_mode = custom_transaction_mode == "AutomaticGroups" + transaction_mode = ( + custom_transaction_mode == Qgis.TransactionMode.AutomaticGroups.name + ) else: # pass transaction_mode as string if transaction_mode is None: @@ -293,14 +295,14 @@ def _create_project(self): transaction_mode = ( "Disabled" if not bool(self.configuration.tool & DbIliMode.gpkg) - else "AutomaticGroups" + else Qgis.TransactionMode.AutomaticGroups.name ) else: # in case the topping used True/False value we need to convert if transaction_mode is True: - transaction_mode = "AutomaticGroups" + transaction_mode = Qgis.TransactionMode.AutomaticGroups.name if transaction_mode is False: - transaction_mode = "Disabled" + transaction_mode = Qgis.TransactionMode.Disabled.name # otherwise it's already a string and could be everything project = Project(