Skip to content

Commit

Permalink
Apply group ordering keys a second time to avoid them being overwritten
Browse files Browse the repository at this point in the history
in the backend
  • Loading branch information
nyalldawson committed Jun 27, 2024
1 parent 9a95b55 commit 8497aa0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
20 changes: 20 additions & 0 deletions felt/core/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,26 @@ def create_layer_groups(self,
for group in json.loads(reply.content().data().decode())
]

def apply_layer_groups_updates(self,
map_id: str,
group_details: List[CreatedGroupDetails]) \
-> QgsNetworkReplyContent:
"""
Updates layer group details
"""
request = self._build_request(
self.LAYER_GROUPS_ENDPOINT.format(map_id),
{'Content-Type': 'application/json'},
version=2
)

group_post_data = [
{'id': g.group_id,
'name': g.name,
'ordering_key': g.ordering_key} for g in
group_details
]

return QgsNetworkAccessManager.instance().blockingPost(
request,
json.dumps(group_post_data).encode()
Expand Down
11 changes: 10 additions & 1 deletion felt/core/map_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ def run(self):
total_steps = (
1 + # create map call
len(self.layers) + # layer exports
len(self.layers) # layer uploads
len(self.layers) + # layer uploads
(1 if self.project_structure.has_groups() else 0) # for final group update
)

self.feedback = QgsFeedback()
Expand Down Expand Up @@ -816,6 +817,14 @@ def _upload_progress(sent, total):

multi_step_feedback.step_finished()

# do this a second time because the order gets overwritten!
if created_group_details:
API_CLIENT.apply_layer_groups_updates(
map_id=self.associated_map.id,
group_details=created_group_details.values()
)
multi_step_feedback.step_finished()

return True

# pylint: enable=too-many-locals
Expand Down

0 comments on commit 8497aa0

Please sign in to comment.