Skip to content

Commit

Permalink
#777 fix workspace clone
Browse files Browse the repository at this point in the history
  • Loading branch information
filippomc committed Jul 28, 2023
1 parent a657aed commit 90248c5
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions applications/workspaces/server/workspaces/service/crud_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,24 +210,25 @@ def clone(self, workspace_id):
user_id = keycloak_user_id()
self.check_max_num_workspaces_per_user(user_id)
from workspaces.service.workflow import clone_workspaces_content
workspace = self.get(workspace_id)
if workspace is None:
raise Exception(
f"Cannot clone workspace with id {workspace_id}: not found.")
workspace.user = None
workspace.id = None
workspace.name = f"Clone of {workspace.name}"
workspace.publicable = False
workspace.featured = False
workspace.timestamp_created = None
cloned = self.to_dao(workspace.to_dict())

with db.session.no_autoflush:
workspace = self.get(workspace_id)
if workspace is None:
raise Exception(
f"Cannot clone workspace with id {workspace_id}: not found.")
workspace.user = None
workspace.id = None
workspace.name = f"Clone of {workspace.name}"
workspace.publicable = False
workspace.featured = False
workspace.timestamp_created = None
cloned = self.to_dao(workspace.to_dict())


cloned = self.repository.post(cloned)
cloned = self.repository.post(cloned)

create_volume(name=self.get_pvc_name(cloned.id),
size=self.get_workspace_volume_size(workspace))
clone_workspaces_content(workspace_id, cloned.id)
create_volume(name=self.get_pvc_name(cloned.id),
size=self.get_workspace_volume_size(workspace))
clone_workspaces_content(workspace_id, cloned.id)
return cloned

def is_authorized(self, workspace):
Expand Down

0 comments on commit 90248c5

Please sign in to comment.