Commit d4140013 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

prevent IntergrityError

parent 4090cf7c
Loading
Loading
Loading
Loading
+7 −3
Changes for rpc/methods.py: 7 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -1945,12 +1945,16 @@ def move_collection(
    _check_project_permission(
        user, child_collection_instance.project, PERM_COLLECTION_UPDATE
    )
    existing_collection = Collection.objects.filter(
        project_id=parent_collection_instance.project_id,
        title=child_collection_instance.title,
        parent_id=parent_collection_instance.id,
    ).first()
    if existing_collection:
        raise ServiceException(COLLECTION_ALREADY_EXIST_IN_PARENT)
    child_collection_instance.parent = parent_collection_instance
    try:
    child_collection_instance.save()
    return True
    except IntegrityError:
        raise ServiceException(COLLECTION_ALREADY_EXIST_IN_PARENT)


@_log_call