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

Cleanup useless function and error handling #650

Merged
merged 1 commit into from
Dec 6, 2024
Merged
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
58 changes: 15 additions & 43 deletions Mergin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ def initGui(self):

self.enable_toolbar_actions()

self.post_login()

self.data_item_provider = DataItemProvider(self)
QgsApplication.instance().dataItemProviderRegistry().addProvider(self.data_item_provider)
# related to https://github.com/MerginMaps/qgis-mergin-plugin/issues/3
Expand Down Expand Up @@ -249,7 +247,6 @@ def on_config_changed(self):
"""Called when plugin config (connection settings) were changed."""
self.create_manager()
self.enable_toolbar_actions()
self.post_login()

def open_configured_url(self, path=None):
"""Opens configured Mergin Maps server url in default browser
Expand Down Expand Up @@ -351,20 +348,21 @@ def set_current_workspace(self, workspace):

if self.mc.server_type() == ServerType.SAAS and workspace_id:
# check action required flag
service_response = self.mc.workspace_service(workspace_id)

if service_response and type(service_response) is dict:
requires_action = service_response.get("action_required", False)

if requires_action:
iface.messageBar().pushMessage(
"Mergin Maps",
"Your attention is required. Please visit the "
f"<a href='{self.mc.url}/dashboard?utm_source=plugin&utm_medium=attention-required'>"
"Mergin dashboard</a>",
level=Qgis.Critical,
duration=0,
)
try:
service_response = self.mc.workspace_service(workspace_id)
except ClientError as e:
return

requires_action = service_response.get("action_required", False)
if requires_action:
iface.messageBar().pushMessage(
"Mergin Maps",
"Your attention is required.&nbsp;Please visit the "
f"<a href='{self.mc.url}/dashboard?utm_source=plugin&utm_medium=attention-required'>"
"Mergin dashboard</a>",
level=Qgis.Critical,
duration=0,
)

def choose_active_workspace(self):
"""
Expand Down Expand Up @@ -402,32 +400,6 @@ def choose_active_workspace(self):

self.set_current_workspace(workspace)

def post_login(self):
"""Groups actions that needs to be done when auth information changes"""
if not self.mc:
return

if self.mc.server_type() != ServerType.OLD:
return

settings = QSettings()

# check action required flag
service_response = self.mc.user_service()

if service_response and type(service_response) is dict:
requires_action = service_response.get("action_required", False)

if requires_action:
iface.messageBar().pushMessage(
"Mergin Maps",
"Your attention is required.&nbsp;Please visit the "
f"<a href='{self.mc.url}/dashboard?utm_source=plugin&utm_medium=attention-required'>"
"Mergin dashboard</a>",
level=Qgis.Critical,
duration=0,
)

def create_new_project(self):
"""Open new Mergin Maps project creation dialog."""
check_result = unsaved_project_check()
Expand Down
Loading