diff --git a/QgisModelBaker/gui/panel/pg_config_panel.py b/QgisModelBaker/gui/panel/pg_config_panel.py
index b2063ba1..fdf1af40 100644
--- a/QgisModelBaker/gui/panel/pg_config_panel.py
+++ b/QgisModelBaker/gui/panel/pg_config_panel.py
@@ -29,6 +29,7 @@
from QgisModelBaker.libs.modelbaker.utils.globals import DbActionType
from QgisModelBaker.utils import gui_utils
+from ...utils.globals import AdministrativeDBActionTypes
from .db_config_panel import DbConfigPanel
WIDGET_UI = gui_utils.get_ui_class("pg_settings_panel.ui")
@@ -78,7 +79,7 @@ def __init__(self, parent, db_action_type):
)
self.pg_use_super_login.setToolTip(
self.tr(
- "Data management tasks are
- Create the schema
- Read meta information
- Import data from XTF
- Export data to XTF
"
+ "Data management tasks are - Create the schema
- Read meta information
- Import data from XTF
"
)
)
@@ -197,6 +198,7 @@ def _show_panel(self):
self.pg_schema_combo_box.lineEdit().setPlaceholderText(
self.tr("[Enter a valid schema]")
)
+ self.pg_use_super_login.setVisible(False)
else:
logging.error(f"Unknown action type: {self._db_action_type}")
@@ -330,8 +332,12 @@ def is_valid(self):
)
self.pg_auth_settings.setFocus()
elif (
- self.pg_auth_settings.configId() and not self.pg_use_super_login.isChecked()
+ self.pg_auth_settings.configId()
+ and not self.pg_use_super_login.isChecked()
+ and self._db_action_type
+ in {item.value for item in AdministrativeDBActionTypes}
):
+ # For Python v3.12+, we can just check like this: self._db_action_type in AdministrativeDBActionTypes
message = self.tr(
"Use superuser login for data management tasks when you use an authentication configuration."
)
diff --git a/QgisModelBaker/utils/globals.py b/QgisModelBaker/utils/globals.py
index f3981606..ab5255a2 100644
--- a/QgisModelBaker/utils/globals.py
+++ b/QgisModelBaker/utils/globals.py
@@ -17,9 +17,12 @@
***************************************************************************/
"""
+from enum import Enum
+
from qgis.PyQt.QtCore import QCoreApplication
from QgisModelBaker.libs.modelbaker.iliwrapper.globals import DbIliMode
+from QgisModelBaker.libs.modelbaker.utils.globals import DbActionType
CRS_PATTERNS = {"LV95": 2056, "LV03": 21781}
@@ -41,3 +44,10 @@
"QgisModelBaker", "Interlis (use SQL Server)"
),
}
+
+
+class AdministrativeDBActionTypes(Enum):
+ """Defines constants for modelbaker actions that require superuser login"""
+
+ GENERATE = DbActionType.GENERATE
+ IMPORT_DATA = DbActionType.IMPORT_DATA