def delete(self, request, repo_id, format=None): """ Unshare a library. Only repo owner can perform this operation. """ share_type = request.GET.get('share_type', '') user = request.GET.get('user', '') group_id = request.GET.get('group_id', '') if not (share_type and user and group_id): return api_error(status.HTTP_400_BAD_REQUEST, 'share_type and user and group_id is required.') if share_type == 'personal': remove_share(repo_id, request.user.username, user) elif share_type == 'group': unshare_group_repo(repo_id, group_id, user) elif share_type == 'public': unset_inner_pub_repo(repo_id) else: return api_error(status.HTTP_400_BAD_REQUEST, 'share_type can only be personal or group or public.') return Response('success', status=status.HTTP_200_OK)
def group_unshare_repo(request, repo_id, group_id, from_email): """ Unshare a repo in group. """ # Check whether group exists group = get_group(group_id) if not group: return render_error(request, _(u"Failed to unshare: the group doesn't exist.")) # Check whether user is group staff or the one share the repo if not check_group_staff(group_id, from_email) and \ seafserv_threaded_rpc.get_group_repo_owner(repo_id) != from_email: return render_permission_error(request, _(u"Operation failed: only administrators and the owner of the library can unshare it.")) if unshare_group_repo(repo_id, group_id, from_email) != 0: return render_error(request, _(u"Failed to unshare: internal error."))