def delete(self, request, group_id, repo_id): """ Delete a group owned library. Permission checking: 1. is group admin; """ repo = seafile_api.get_repo(repo_id) if not repo: error_msg = 'Library %s not found.' % repo_id return api_error(status.HTTP_404_NOT_FOUND, error_msg) group_id = int(group_id) username = request.user.username if not is_group_admin(group_id, username): error_msg = 'Permission denied.' return api_error(status.HTTP_403_FORBIDDEN, error_msg) try: seafile_api.delete_group_owned_repo(group_id, repo_id) except Exception as e: logger.error(e) error_msg = 'Internal Server Error' return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) return Response({'success': True})
def delete(self, request, group_id, repo_id): """ Delete a group owned library by system admin. """ if not request.user.admin_permissions.can_manage_group(): return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.') repo = seafile_api.get_repo(repo_id) if not repo: error_msg = 'Library %s not found.' % repo_id return api_error(status.HTTP_404_NOT_FOUND, error_msg) group_id = int(group_id) try: if is_org_context(request): # request called by org admin org_id = request.user.org.org_id seafile_api.org_delete_group_owned_repo(org_id, group_id, repo_id) else: seafile_api.delete_group_owned_repo(group_id, repo_id) except Exception as e: logger.error(e) error_msg = 'Internal Server Error' return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) return Response({'success': True})
def delete(self, request, group_id, repo_id): """ Delete a group owned library. """ repo = seafile_api.get_repo(repo_id) if not repo: error_msg = 'Library %s not found.' % repo_id return api_error(status.HTTP_404_NOT_FOUND, error_msg) group_id = int(group_id) try: seafile_api.delete_group_owned_repo(group_id, repo_id) except Exception as e: logger.error(e) error_msg = 'Internal Server Error' return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) return Response({'success': True})
def delete(self, request, group_id, repo_id): """ Delete a group owned library by system admin. """ repo = seafile_api.get_repo(repo_id) if not repo: error_msg = 'Library %s not found.' % repo_id return api_error(status.HTTP_404_NOT_FOUND, error_msg) group_id = int(group_id) try: if is_org_context(request): # request called by org admin org_id = request.user.org.org_id seafile_api.org_delete_group_owned_repo(org_id, group_id, repo_id) else: seafile_api.delete_group_owned_repo(group_id, repo_id) except Exception as e: logger.error(e) error_msg = 'Internal Server Error' return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) return Response({'success': True})
def delete_group_owned_repo(self, group_id, repo_id, org_id=None): if is_valid_org_id(org_id): return seafile_api.org_delete_group_owned_repo( org_id, group_id, repo_id) else: return seafile_api.delete_group_owned_repo(group_id, repo_id)
def delete_group_owned_repo(self, group_id, repo_id, org_id=None): if is_valid_org_id(org_id): return seafile_api.org_delete_group_owned_repo(org_id, group_id, repo_id) else: return seafile_api.delete_group_owned_repo(group_id, repo_id)