Skip to content

Commit

Permalink
Merge pull request #962 from opengisch/fix_905
Browse files Browse the repository at this point in the history
[export] Hide superuser checkbox on PG export and make it possible to run PG export with authConfig and no superuser
  • Loading branch information
signedav authored Oct 7, 2024
2 parents fbfc0de + ccf1eb2 commit fd0bd7f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions QgisModelBaker/gui/panel/pg_config_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -78,7 +79,7 @@ def __init__(self, parent, db_action_type):
)
self.pg_use_super_login.setToolTip(
self.tr(
"Data management tasks are <ul><li>Create the schema</li><li>Read meta information</li><li>Import data from XTF</li><li>Export data to XTF</li></ul>"
"Data management tasks are <ul><li>Create the schema</li><li>Read meta information</li><li>Import data from XTF</li></ul>"
)
)

Expand Down Expand Up @@ -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}")

Expand Down Expand Up @@ -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."
)
Expand Down
10 changes: 10 additions & 0 deletions QgisModelBaker/utils/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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

0 comments on commit fd0bd7f

Please sign in to comment.