mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-23 17:20:29 +00:00
admin-rename-lib
This commit is contained in:
parent
8d196077bf
commit
06c9fb65cc
@ -278,7 +278,7 @@ class AdminLibrary(APIView):
|
|||||||
return Response({'success': True})
|
return Response({'success': True})
|
||||||
|
|
||||||
def put(self, request, repo_id, format=None):
|
def put(self, request, repo_id, format=None):
|
||||||
""" transfer a library
|
""" transfer a library, rename a library
|
||||||
|
|
||||||
Permission checking:
|
Permission checking:
|
||||||
1. only admin can perform this action.
|
1. only admin can perform this action.
|
||||||
@ -288,11 +288,24 @@ class AdminLibrary(APIView):
|
|||||||
error_msg = 'Library %s not found.' % repo_id
|
error_msg = 'Library %s not found.' % repo_id
|
||||||
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
|
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
|
||||||
|
|
||||||
new_owner = request.data.get('owner', None)
|
new_repo_name = request.data.get('name', None)
|
||||||
if not new_owner:
|
if new_repo_name:
|
||||||
error_msg = 'owner invalid.'
|
try:
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
res = seafile_api.edit_repo(repo_id, new_repo_name, '', None)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
error_msg = 'Internal Server Error'
|
||||||
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||||
|
|
||||||
|
if res == -1:
|
||||||
|
e = 'Admin rename failed: ID of library is %s, edit_repo api called failed.' % \
|
||||||
|
repo_id
|
||||||
|
logger.error(e)
|
||||||
|
error_msg = 'Internal Server Error'
|
||||||
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||||
|
|
||||||
|
new_owner = request.data.get('owner', None)
|
||||||
|
if new_owner:
|
||||||
try:
|
try:
|
||||||
new_owner_obj = User.objects.get(email=new_owner)
|
new_owner_obj = User.objects.get(email=new_owner)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
|
Loading…
Reference in New Issue
Block a user