Skip to content

Commit

Permalink
Merge branch 'master' into project-history-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinBuira committed Dec 6, 2024
2 parents 34c8898 + d75fa88 commit c81e9fe
Showing 1 changed file with 15 additions and 43 deletions.
58 changes: 15 additions & 43 deletions Mergin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,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 @@ -261,7 +259,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 @@ -367,20 +364,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 @@ -418,32 +416,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

0 comments on commit c81e9fe

Please sign in to comment.