Skip to content

Commit

Permalink
adding invalid URL messages during typing
Browse files Browse the repository at this point in the history
  • Loading branch information
Gpetrak committed Nov 13, 2024
1 parent 785c802 commit 74246ef
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions src/qgis_geonode/gui/connection_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,29 +168,20 @@ def test_connection(self):
for widget in self._widgets_to_toggle_during_connection_test:
widget.setEnabled(False)

url_status = self.validate_geonode_url()

if url_status != False:

current_settings = self.get_connection_settings()
self.discovery_task = network.NetworkRequestTask(
[
network.RequestToPerform(
QtCore.QUrl(f"{current_settings.base_url}/version.txt")
)
],
network_task_timeout=current_settings.network_requests_timeout,
authcfg=current_settings.auth_config,
description="Connect to a GeoNode client",
)
self.discovery_task.task_done.connect(self.handle_discovery_test)
utils.show_message(self.bar, tr("Connecting..."), add_loading_widget=True)
qgis.core.QgsApplication.taskManager().addTask(self.discovery_task)
else:
self.enable_post_test_connection_buttons()
message = "Please insert only the domain of a valid GeoNode URL"
level = qgis.core.Qgis.Critical
utils.show_message(self.bar, message, level)
current_settings = self.get_connection_settings()
self.discovery_task = network.NetworkRequestTask(
[
network.RequestToPerform(
QtCore.QUrl(f"{current_settings.base_url}/version.txt")
)
],
network_task_timeout=current_settings.network_requests_timeout,
authcfg=current_settings.auth_config,
description="Connect to a GeoNode client",
)
self.discovery_task.task_done.connect(self.handle_discovery_test)
utils.show_message(self.bar, tr("Connecting..."), add_loading_widget=True)
qgis.core.QgsApplication.taskManager().addTask(self.discovery_task)

def handle_discovery_test(self, task_result: bool):
self.enable_post_test_connection_buttons()
Expand Down Expand Up @@ -304,6 +295,10 @@ def update_ok_buttons(self):
self.connection_pb.setEnabled(enabled_state)
if url_status != True:
self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
self.connection_pb.setEnabled(False)
message = "Please insert only the domain of a valid GeoNode URL"
level = qgis.core.Qgis.Info
utils.show_message(self.bar, message, level)


def _get_wfs_declared_versions(raw_response: QtCore.QByteArray) -> typing.List[str]:
Expand Down

0 comments on commit 74246ef

Please sign in to comment.