mirror of
https://github.com/clearml/clearml-server
synced 2025-05-11 15:21:30 +00:00
Fix no destination when merging projects
This commit is contained in:
parent
65cb8d7b43
commit
174f84514a
@ -63,20 +63,24 @@ class ProjectBLL:
|
|||||||
source=source_id
|
source=source_id
|
||||||
)
|
)
|
||||||
source = Project.get(company, source_id)
|
source = Project.get(company, source_id)
|
||||||
destination = Project.get(company, destination_id)
|
if destination_id:
|
||||||
if source_id in destination.path:
|
destination = Project.get(company, destination_id)
|
||||||
raise errors.bad_request.ProjectCannotBeMergedIntoItsChild(
|
if source_id in destination.path:
|
||||||
source=source_id, destination=destination_id
|
raise errors.bad_request.ProjectCannotBeMergedIntoItsChild(
|
||||||
)
|
source=source_id, destination=destination_id
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
destination = None
|
||||||
|
|
||||||
children = _get_sub_projects(
|
children = _get_sub_projects(
|
||||||
[source.id], _only=("id", "name", "parent", "path")
|
[source.id], _only=("id", "name", "parent", "path")
|
||||||
)[source.id]
|
)[source.id]
|
||||||
cls.validate_projects_depth(
|
if destination:
|
||||||
projects=children,
|
cls.validate_projects_depth(
|
||||||
old_parent_depth=len(source.path) + 1,
|
projects=children,
|
||||||
new_parent_depth=len(destination.path) + 1,
|
old_parent_depth=len(source.path) + 1,
|
||||||
)
|
new_parent_depth=len(destination.path) + 1,
|
||||||
|
)
|
||||||
|
|
||||||
moved_entities = 0
|
moved_entities = 0
|
||||||
for entity_type in (Task, Model):
|
for entity_type in (Task, Model):
|
||||||
@ -147,10 +151,8 @@ class ProjectBLL:
|
|||||||
raise errors.bad_request.ProjectSourceAndDestinationAreTheSame(
|
raise errors.bad_request.ProjectSourceAndDestinationAreTheSame(
|
||||||
location=new_parent.name if new_parent else ""
|
location=new_parent.name if new_parent else ""
|
||||||
)
|
)
|
||||||
if (
|
if new_parent and (
|
||||||
new_parent
|
project_id == new_parent.id or project_id in new_parent.path
|
||||||
and project_id == new_parent.id
|
|
||||||
or project_id in new_parent.path
|
|
||||||
):
|
):
|
||||||
raise errors.bad_request.ProjectCannotBeMovedUnderItself(
|
raise errors.bad_request.ProjectCannotBeMovedUnderItself(
|
||||||
project=project_id, parent=new_parent.id
|
project=project_id, parent=new_parent.id
|
||||||
|
Loading…
Reference in New Issue
Block a user