feat: Add the is_installed field to the Service

This commit is contained in:
Inex Code 2024-07-23 20:02:18 +03:00
parent 0384d7585a
commit 0d69ba2656
2 changed files with 12 additions and 0 deletions

View file

@ -175,6 +175,7 @@ class Service:
is_movable: bool
is_required: bool
is_enabled: bool
is_installed: bool
can_be_backed_up: bool
backup_description: str
status: ServiceStatusEnum
@ -232,6 +233,7 @@ def service_to_graphql_service(service: ServiceInterface) -> Service:
is_movable=service.is_movable(),
is_required=service.is_required(),
is_enabled=service.is_enabled(),
is_installed=service.is_installed(),
can_be_backed_up=service.can_be_backed_up(),
backup_description=service.get_backup_description(),
status=ServiceStatusEnum(service.get_status().value),

View file

@ -146,6 +146,16 @@ class Service(ABC):
with ReadUserData() as user_data:
return user_data.get("modules", {}).get(name, {}).get("enable", False)
@classmethod
def is_installed(cls) -> bool:
"""
`True` if the service is installed.
`False` if there is no module data in user data
"""
name = cls.get_id()
with ReadUserData() as user_data:
return user_data.get("modules", {}).get(name, {}) != {}
@staticmethod
@abstractmethod
def get_status() -> ServiceStatus: