Skip to content

Commit

Permalink
Views: Include workspace details in the response
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Puerto committed Jan 7, 2025
1 parent 8f59ff0 commit 2ed8a28
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/user_workspaces_server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ def get_query_param_fields():
@staticmethod
def get_dict_fields():
return [
"original_workspace_id",
"shared_workspace_id",
"is_accepted",
"last_params",
"last_job_type",
Expand Down
24 changes: 20 additions & 4 deletions src/user_workspaces_server/views/shared_workspace_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,31 @@ def get(self, request, shared_workspace_id=None):
original_workspaces = original_workspaces.filter(**{key: params[key]})
shared_workspaces = shared_workspaces.filter(**{key: params[key]})

dict_fields = models.SharedWorkspaceMapping.get_dict_fields()
shared_workspace_dict_fields = models.SharedWorkspaceMapping.get_dict_fields()

original_workspaces = list(original_workspaces.all().values(*dict_fields))
shared_workspaces = list(shared_workspaces.all().values(*dict_fields))
workspace_dict_fields = [
"id",
"name",
"description",
"user_id__first_name",
"user_id__last_name",
]

shared_workspace_dict_fields.extend(
[
prefix + dict_field
for prefix in ["original_workspace_id__", "shared_workspace_id__"]
for dict_field in workspace_dict_fields
]
)

original_workspaces = list(original_workspaces.all().values(*shared_workspace_dict_fields))
shared_workspaces = list(shared_workspaces.all().values(*shared_workspace_dict_fields))

response = {
"message": "Successful.",
"success": True,
"data": {"sent": [], "received": []},
"data": {"original_workspaces": [], "shared_workspaces": []},
}

if original_workspaces or shared_workspaces:
Expand Down

0 comments on commit 2ed8a28

Please sign in to comment.