def test_share_dir_to_user(repo, permission): v_repo_id_1 = api.share_subdir_to_user(repo.id, '/dir1', USER, USER2, permission) v_repo_id_2 = api.share_subdir_to_user(repo.id, '/dir2', USER, USER2, permission) assert api.check_permission(v_repo_id_1, USER2) == permission assert api.check_permission(v_repo_id_2, USER2) == permission vir_repo_2 = api.get_shared_repo_by_path(repo.id, '/dir2', USER2) assert vir_repo_2.permission == permission assert api.del_file(repo.id, '/', 'dir1', USER) == 0 assert api.unshare_subdir_for_user(repo.id, '/dir2', USER, USER2) == 0 assert api.get_shared_repo_by_path(repo.id, '/dir1', USER2) is None assert api.get_shared_repo_by_path(repo.id, '/dir2', USER2) is None
def check_user_share_in_permission(repo_id, share_to, is_org=False): # Return the permission to share to you. repo = seafile_api.get_shared_repo_by_path(repo_id, None, share_to, is_org) if not repo: return None extra_permission = ExtraSharePermission.objects.get_user_permission(repo_id, share_to) return extra_permission if extra_permission else repo.permission
def check_user_share_in_permission(repo_id, share_to, is_org=False): # Return the permission to share to you. repo = seafile_api.get_shared_repo_by_path(repo_id, None, share_to, is_org) if not repo: return None extra_permission = ExtraSharePermission.objects.get_user_permission(repo_id, share_to) return extra_permission if extra_permission else repo.permission
def test_share_dir_to_user(repo, permission): v_repo_id_1 = api.share_subdir_to_user(repo.id, '/dir1', USER, USER2, permission) v_repo_id_2 = api.share_subdir_to_user(repo.id, '/dir2', USER, USER2, permission) assert api.check_permission(v_repo_id_1, USER2) == permission assert api.check_permission(v_repo_id_2, USER2) == permission vir_repo_2 = api.get_shared_repo_by_path(repo.id, '/dir2', USER2) assert vir_repo_2.permission == permission users = api.get_shared_users_for_subdir(repo.id, '/dir1', USER) assert len(users) == 1 and users[0].user == USER2 assert api.del_file(repo.id, '/', 'dir1', USER) == 0 assert api.unshare_subdir_for_user(repo.id, '/dir2', USER, USER2) == 0 time.sleep(1) assert api.get_shared_repo_by_path(repo.id, '/dir1', USER2) is None assert api.get_shared_repo_by_path(repo.id, '/dir2', USER2) is None
def check_user_share_out_permission(repo_id, path, share_to, is_org=False): # Return the permission you share to others. path = None if path == '/' else path repo = seafile_api.get_shared_repo_by_path(repo_id, path, share_to, is_org) if not repo: return None permission = repo.permission if path is None: extra_permission = ExtraSharePermission.objects.get_user_permission(repo_id, share_to) permission = extra_permission if extra_permission else repo.permission return permission
def check_user_share_out_permission(repo_id, path, share_to, is_org=False): # Return the permission you share to others. path = None if path == '/' else path repo = seafile_api.get_shared_repo_by_path(repo_id, path, share_to, is_org) if not repo: return None permission = repo.permission if path is None: extra_permission = ExtraSharePermission.objects.get_user_permission(repo_id, share_to) permission = extra_permission if extra_permission else repo.permission return permission