Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[export] Hide superuser checkbox on PG export and make it possible to run PG export with authConfig and no superuser #962

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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