db/python/tables/project.py
async def check_access_to_project_ids(
        self,
        user: str,
        project_ids: Iterable[ProjectId],
        readonly: bool,
        raise_exception=True,
    ) -> bool:
        """Check user has access to list of project_ids"""
        if not project_ids:
            raise Forbidden(
                "You don't have access to this resources, as the resource you requested didn't belong to a project"
            )
        if self.allow_full_access:
            return True
        missing_project_ids = []
        spids = set(project_ids)
        for project_id in spids:
            has_access = await self.check_access_to_project_id(
                user, project_id, readonly=readonly, raise_exception=False
            )
            if not has_access:
                missing_project_ids.append(project_id)

        if missing_project_ids:
            if raise_exception:
                project_map = await self.get_project_id_map()
                missing_project_names = [
                    project_map[pid].name for pid in missing_project_ids
                ]
                raise NoProjectAccess(
                    missing_project_names, readonly=readonly, author=user
                )
            return False

        return True
Check user has access to list of project_ids
Check user has access to list of project_ids
Check user has access to list of project_ids
async def check_access_to_project_ids(
        self,
        user: str,
        project_ids: Iterable[ProjectId],
        readonly: bool,
        raise_exception=True,
    ) -> bool:
        if not project_ids:
            raise Forbidden(
                "You don't have access to this resources, as the resource you requested didn't belong to a project"
            )
        if self.allow_full_access:
            return True
        missing_project_ids = []
        spids = set(project_ids)
        for project_id in spids:
            has_access = await self.check_access_to_project_id(
                user, project_id, readonly=readonly, raise_exception=False
            )
            if not has_access:
                missing_project_ids.append(project_id)
        if missing_project_ids:
            if raise_exception:
                project_map = await self.get_project_id_map()
                missing_project_names = [
                    project_map[pid].name for pid in missing_project_ids
                ]
                raise NoProjectAccess(
                    missing_project_names, readonly=readonly, author=user
                )
            return False
        return True
async def check_access_to_project_ids ( self , user : str , project_ids : Iterable [ ProjectId ] , readonly : bool , raise_exception = True , ) -> bool : if not project_ids : raise Forbidden ( "You don't have access to this resources, as the resource you requested didn't belong to a project" ) if self . allow_full_access : return True missing_project_ids = [ ] spids = set ( project_ids ) for project_id in spids : has_access = await self . check_access_to_project_id ( user , project_id , readonly = readonly , raise_exception = False ) if not has_access : missing_project_ids . append ( project_id ) if missing_project_ids : if raise_exception : project_map = await self . get_project_id_map ( ) missing_project_names = [ project_map [ pid ] . name for pid in missing_project_ids ] raise NoProjectAccess ( missing_project_names , readonly = readonly , author = user ) return False return True
Check user has access to list of project_ids
Check user has access to list of project_ids
"""Check user has access to list of project_ids"""
self
user
str
project_ids
Iterable[ProjectId]
readonly
bool
raise_exception