# 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
    def has_permission(self, permission: str) -> bool:
        return self.permissions.get(permission, False)

    async def has_right_on_analysis(self, analysis_id: str, right: Right) -> bool:
        return True

    async def has_right_on_hmms(self, right: Right):
        if right == READ:
            return True

        if right == MODIFY or right == REMOVE:
            return self.has_permission("modify_hmm")

    async def has_right_on_index(self, index_id: str, right: Right) -> bool:
        return True if right == READ else False

    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"])


# 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

    def has_permission(self, permission: str) -> bool:
        return self.permissions.get(permission, False)

    async def has_right_on_analysis(self, analysis_id: str, right: Right) -> bool:
        return True

    async def has_right_on_hmms(self, right: Right):
        if right == READ:
            return True

        if right == MODIFY or right == REMOVE:
            return self.has_permission("modify_hmm")

    async def has_right_on_index(self, index_id: str, right: Right) -> bool:
        return True if right == READ else False

    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: