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

If no user name (or auth config) is chosen, we fill up the user name … #972

Merged
merged 6 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
7 changes: 2 additions & 5 deletions QgisModelBaker/gui/panel/dataset_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
)
from QgisModelBaker.libs.modelbaker.utils.db_utils import (
get_configuration_from_sourceprovider,
get_db_connector,
get_schema_identificator_from_sourceprovider,
)
from QgisModelBaker.libs.modelbaker.utils.qt_utils import slugify
Expand Down Expand Up @@ -82,12 +83,8 @@ def set_current_layer(self, layer):
source_provider, configuration
)
if valid and mode:
db_factory = self.db_simple_factory.create_factory(mode)
config_manager = db_factory.get_db_command_config_manager(configuration)
try:
db_connector = db_factory.get_db_connector(
config_manager.get_uri(), configuration.dbschema
)
db_connector = get_db_connector(configuration)
if db_connector.get_basket_handling():
self.basket_model.reload_schema_baskets(
db_connector,
Expand Down
9 changes: 0 additions & 9 deletions QgisModelBaker/gui/panel/pg_config_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,6 @@ def is_valid(self):
elif not self.pg_database_line_edit.text().strip():
message = self.tr("Please set a database before creating the project.")
self.pg_database_line_edit.setFocus()
elif (
not self.pg_auth_settings.username()
and not self.pg_auth_settings.configId()
):
message = self.tr(
"Please set a username or select an authentication configuration before creating the "
"project."
)
self.pg_auth_settings.setFocus()
elif (
self.pg_auth_settings.configId()
and not self.pg_use_super_login.isChecked()
Expand Down
10 changes: 9 additions & 1 deletion QgisModelBaker/gui/panel/session_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import os

from qgis.core import QgsApplication
from qgis.PyQt.QtCore import Qt, pyqtSignal
from qgis.PyQt.QtWidgets import QAction, QApplication, QMessageBox, QWidget

Expand All @@ -34,7 +35,7 @@
from QgisModelBaker.libs.modelbaker.iliwrapper.ili2dbutils import JavaNotFoundError
from QgisModelBaker.libs.modelbaker.utils.globals import DbActionType
from QgisModelBaker.libs.modelbaker.utils.qt_utils import OverrideCursor
from QgisModelBaker.utils.globals import DEFAULT_DATASETNAME
from QgisModelBaker.utils.globals import DEFAULT_DATASETNAME, DbIliMode
from QgisModelBaker.utils.gui_utils import LogLevel

WIDGET_UI = gui_utils.get_ui_class("workflow_wizard/session_panel.ui")
Expand Down Expand Up @@ -108,6 +109,13 @@ def __init__(

# set up the values
self.configuration = general_configuration
if self.configuration.tool & DbIliMode.pg:
# on pg we should consider the user account name as fallback
if (
not self.configuration.db_use_super_login
and not self.configuration.dbusr
):
self.configuration.dbusr = QgsApplication.userLoginName()
if self.db_action_type == DbActionType.GENERATE:
self.configuration.ilifile = ""
if os.path.isfile(self.file):
Expand Down
7 changes: 7 additions & 0 deletions QgisModelBaker/gui/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ def _run(self, edited_command=None):

validator.tool = self.current_configuration.tool
validator.configuration = self.current_configuration
if validator.configuration.tool & DbIliMode.pg:
# on pg we should consider the user account name as fallback
if (
not validator.configuration.db_use_super_login
and not validator.configuration.dbusr
):
validator.configuration.dbusr = QgsApplication.userLoginName()

validator.configuration.ilimodels = ""
validator.configuration.dataset = ""
Expand Down
11 changes: 8 additions & 3 deletions QgisModelBaker/gui/workflow_wizard/project_creation_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import re

import yaml
from qgis.core import Qgis, QgsProject
from qgis.core import Qgis, QgsApplication, QgsProject
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtWidgets import QCompleter, QWizardPage

Expand Down Expand Up @@ -332,7 +332,10 @@ def _create_project(self):
self.configuration
)
uri = config_manager.get_uri(qgis=True)
mgmt_uri = config_manager.get_uri(self.configuration.db_use_super_login)
mgmt_uri = config_manager.get_uri(
su=self.configuration.db_use_super_login,
fallback_user=QgsApplication.userLoginName(),
)
generator = Generator(
self.configuration.tool,
uri,
Expand Down Expand Up @@ -375,7 +378,9 @@ def _create_project(self):
self.progress_bar.setValue(0)
return

res, message = db_factory.post_generate_project_validations(self.configuration)
res, message = db_factory.post_generate_project_validations(
self.configuration, QgsApplication.userLoginName()
)

if not res:
self.workflow_wizard.log_panel.txtStdout.setText(message)
Expand Down