mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 19:08:21 +00:00
[transfer repo] add more comment
This commit is contained in:
@@ -1114,19 +1114,24 @@ class RepoOwner(APIView):
|
|||||||
error_msg = 'Permission denied.'
|
error_msg = 'Permission denied.'
|
||||||
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
||||||
|
|
||||||
# get users/groups repo already shared to
|
|
||||||
if org_id:
|
if org_id:
|
||||||
|
# get repo shared to user/group list
|
||||||
shared_users = seafile_api.list_org_repo_shared_to(org_id,
|
shared_users = seafile_api.list_org_repo_shared_to(org_id,
|
||||||
repo_owner, repo_id)
|
repo_owner, repo_id)
|
||||||
shared_groups = seafile_api.list_org_repo_shared_group(org_id,
|
shared_groups = seafile_api.list_org_repo_shared_group(org_id,
|
||||||
repo_owner, repo_id)
|
repo_owner, repo_id)
|
||||||
|
|
||||||
|
# get all pub repos
|
||||||
pub_repos = seaserv.seafserv_threaded_rpc.list_org_inner_pub_repos_by_owner(
|
pub_repos = seaserv.seafserv_threaded_rpc.list_org_inner_pub_repos_by_owner(
|
||||||
org_id, repo_owner)
|
org_id, repo_owner)
|
||||||
else:
|
else:
|
||||||
|
# get repo shared to user/group list
|
||||||
shared_users = seafile_api.list_repo_shared_to(
|
shared_users = seafile_api.list_repo_shared_to(
|
||||||
repo_owner, repo_id)
|
repo_owner, repo_id)
|
||||||
shared_groups = seafile_api.list_repo_shared_group_by_user(
|
shared_groups = seafile_api.list_repo_shared_group_by_user(
|
||||||
repo_owner, repo_id)
|
repo_owner, repo_id)
|
||||||
|
|
||||||
|
# get all pub repos
|
||||||
pub_repos = seaserv.seafserv_threaded_rpc.list_inner_pub_repos_by_owner(
|
pub_repos = seaserv.seafserv_threaded_rpc.list_inner_pub_repos_by_owner(
|
||||||
repo_owner)
|
repo_owner)
|
||||||
|
|
||||||
@@ -1146,7 +1151,7 @@ class RepoOwner(APIView):
|
|||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||||
|
|
||||||
# reshare repo
|
# reshare repo to user
|
||||||
for shared_user in shared_users:
|
for shared_user in shared_users:
|
||||||
shared_username = shared_user.user
|
shared_username = shared_user.user
|
||||||
|
|
||||||
@@ -1160,6 +1165,7 @@ class RepoOwner(APIView):
|
|||||||
seafile_api.share_repo(repo_id, new_owner,
|
seafile_api.share_repo(repo_id, new_owner,
|
||||||
shared_username, shared_user.perm)
|
shared_username, shared_user.perm)
|
||||||
|
|
||||||
|
# reshare repo to group
|
||||||
for shared_group in shared_groups:
|
for shared_group in shared_groups:
|
||||||
shared_group_id = shared_group.group_id
|
shared_group_id = shared_group.group_id
|
||||||
|
|
||||||
@@ -1173,6 +1179,8 @@ class RepoOwner(APIView):
|
|||||||
seafile_api.set_group_repo(repo_id, shared_group_id,
|
seafile_api.set_group_repo(repo_id, shared_group_id,
|
||||||
new_owner, shared_group.perm)
|
new_owner, shared_group.perm)
|
||||||
|
|
||||||
|
# check if current repo is pub-repo
|
||||||
|
# if YES, reshare current repo to public
|
||||||
for pub_repo in pub_repos:
|
for pub_repo in pub_repos:
|
||||||
if repo_id != pub_repo.id:
|
if repo_id != pub_repo.id:
|
||||||
continue
|
continue
|
||||||
|
@@ -1612,17 +1612,21 @@ def sys_repo_transfer(request):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
repo_owner = seafile_api.get_repo_owner(repo_id)
|
repo_owner = seafile_api.get_repo_owner(repo_id)
|
||||||
|
|
||||||
|
# get repo shared to user/group list
|
||||||
shared_users = seafile_api.list_repo_shared_to(
|
shared_users = seafile_api.list_repo_shared_to(
|
||||||
repo_owner, repo_id)
|
repo_owner, repo_id)
|
||||||
shared_groups = seafile_api.list_repo_shared_group_by_user(
|
shared_groups = seafile_api.list_repo_shared_group_by_user(
|
||||||
repo_owner, repo_id)
|
repo_owner, repo_id)
|
||||||
|
|
||||||
|
# get all pub repos
|
||||||
pub_repos = seaserv.seafserv_threaded_rpc.list_inner_pub_repos_by_owner(
|
pub_repos = seaserv.seafserv_threaded_rpc.list_inner_pub_repos_by_owner(
|
||||||
repo_owner)
|
repo_owner)
|
||||||
|
|
||||||
# transfer repo
|
# transfer repo
|
||||||
seafile_api.set_repo_owner(repo_id, new_owner)
|
seafile_api.set_repo_owner(repo_id, new_owner)
|
||||||
|
|
||||||
# reshare repo
|
# reshare repo to user
|
||||||
for shared_user in shared_users:
|
for shared_user in shared_users:
|
||||||
shared_username = shared_user.user
|
shared_username = shared_user.user
|
||||||
|
|
||||||
@@ -1632,6 +1636,7 @@ def sys_repo_transfer(request):
|
|||||||
seafile_api.share_repo(repo_id, new_owner,
|
seafile_api.share_repo(repo_id, new_owner,
|
||||||
shared_username, shared_user.perm)
|
shared_username, shared_user.perm)
|
||||||
|
|
||||||
|
# reshare repo to group
|
||||||
for shared_group in shared_groups:
|
for shared_group in shared_groups:
|
||||||
shared_group_id = shared_group.group_id
|
shared_group_id = shared_group.group_id
|
||||||
|
|
||||||
@@ -1641,6 +1646,8 @@ def sys_repo_transfer(request):
|
|||||||
seafile_api.set_group_repo(repo_id, shared_group_id,
|
seafile_api.set_group_repo(repo_id, shared_group_id,
|
||||||
new_owner, shared_group.perm)
|
new_owner, shared_group.perm)
|
||||||
|
|
||||||
|
# check if current repo is pub-repo
|
||||||
|
# if YES, reshare current repo to public
|
||||||
for pub_repo in pub_repos:
|
for pub_repo in pub_repos:
|
||||||
if repo_id != pub_repo.id:
|
if repo_id != pub_repo.id:
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user