# Path: virtool/http/rights.py
# READ = "read"
# MODIFY = "modify"
# REMOVE = "remove"


from abc import ABC, abstractmethod
from typing import Dict, Optional, Sequence, Union
from virtool.http.rights import MODIFY, READ, REMOVE, Right
from virtool.jobs.utils import JobRights
    async def has_right_on_sample(self, sample_id: str, right: Right) -> bool:
        if self.administrator:
            return True

        sample = await self._db.find_one(sample_id, {"quality": False})

        if self.user_id == sample["user"]["id"]:
            return True

        is_group_member = sample["group"] and sample["group"] in self.groups

        if right == READ:
            return sample["all_read"] or (is_group_member and sample["group_read"])

        if right == MODIFY or right == REMOVE:
            return sample["all_write"] or (is_group_member and sample["group_write"])

    async def has_right_on_reference(self, reference_id: str, right: Right):
        return False

    async def has_right_on_subtraction(self, subtraction_id: str, right: Right):
        """
        Check whether the authenticated user has the passed ``right`` on a subtraction.

        User rights on subtractions are based on group permissions.

        """
        if right == READ:
            return True


# Path: virtool/http/rights.py
# READ = "read"
# MODIFY = "modify"
# REMOVE = "remove"


# Path: virtool/http/client.py
from abc import ABC, abstractmethod
from typing import Dict, Optional, Sequence, Union
from virtool.http.rights import MODIFY, READ, REMOVE, Right
from virtool.jobs.utils import JobRights

    async def has_right_on_sample(self, sample_id: str, right: Right) -> bool:
        if self.administrator:
            return True

        sample = await self._db.find_one(sample_id, {"quality": False})

        if self.user_id == sample["user"]["id"]:
            return True

        is_group_member = sample["group"] and sample["group"] in self.groups

        if right == READ:
            return sample["all_read"] or (is_group_member and sample["group_read"])

        if right == MODIFY or right == REMOVE:
            return sample["all_write"] or (is_group_member and sample["group_write"])

    async def has_right_on_reference(self, reference_id: str, right: Right):
        return False

    async def has_right_on_subtraction(self, subtraction_id: str, right: Right):
        """
        Check whether the authenticated user has the passed ``right`` on a subtraction.

        User rights on subtractions are based on group permissions.

        """
        if right == READ:
            return True


        if right == MODIFY: