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

feature/812 - fix for - Error when deleting the Workspace Resources #908

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BaseModelRepository:
def __init__(self, model=None):
if model:
self.model = model


def _get(self, id):
"""
Expand Down Expand Up @@ -247,8 +247,11 @@ def delete(self, id):

if not result:
return f"{self.model.__name__} with id {id} not found.", 404

db.session.delete(result)
return db.session.commit()



def __str__(self):
return self.model.__tablename__
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,4 @@ def open(self, workspace_resource):
def delete(self, id):
"""Delete an object from the repository."""
workspace_resource = self.get(id)
super().delete(id)
super().delete(id)
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 @@ -516,6 +517,7 @@ def is_authorized(self, resource: WorkspaceResourceEntity):

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

return workspace_resource

def delete(self, id_):
Expand Down
Loading