Skip to content

Commit

Permalink
#8122 fix the mapper for to_dto in workspace resource entitiy
Browse files Browse the repository at this point in the history
  • Loading branch information
D-GopalKrishna committed Feb 13, 2024
1 parent 54e0c2d commit cd73def
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,15 @@ def to_dao(cls, ws_dict: dict) -> TWorkspaceResourceEntity:

@classmethod
def to_dto(cls, resource) -> Model:
resource.origin = json.loads(resource.origin)
if resource.folder: # Legacy folder/path handling
resource_dict = dao_entity2dict(resource)
resource_dict['origin'] = json.loads(resource.origin)
if resource_dict['folder']: # Legacy folder/path handling

# Legacy folder/path handling
if resource.origin.get("folder", None) is not None:
resource.origin["path"] = resource.origin.get("folder")
del resource.origin["folder"]
dto = cls._calculated_fields_populate(cls.dict_to_dto(dao_entity2dict(resource)))
if resource_dict['origin'].get("folder", None) is not None:
resource_dict['origin']["path"] = resource_dict['origin'].get("folder")
del resource_dict['origin']["folder"]
dto = cls._calculated_fields_populate(cls.dict_to_dto(resource_dict))
dto.path = resource.folder
return dto

Expand Down Expand Up @@ -515,13 +516,13 @@ def is_authorized(self, resource: WorkspaceResourceEntity):
return True

def get(self, id_):
workspace_resource = WorkspaceResourceRepository().get(id_)
workspace_resource = super().get(id_)

return workspace_resource

def delete(self, id_):
workspace_resource = self.get(id_)
WorkspaceResourceRepository().delete(id_)
super().delete(id_)
from workspaces.helpers.etl_helpers import delete_workspace_resource
delete_workspace_resource(workspace_resource)

Expand Down

0 comments on commit cd73def

Please sign in to comment.