mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 04:01:27 +00:00
feat: Add the is_installed field to the Service
This commit is contained in:
parent
0384d7585a
commit
0d69ba2656
|
@ -175,6 +175,7 @@ class Service:
|
||||||
is_movable: bool
|
is_movable: bool
|
||||||
is_required: bool
|
is_required: bool
|
||||||
is_enabled: bool
|
is_enabled: bool
|
||||||
|
is_installed: bool
|
||||||
can_be_backed_up: bool
|
can_be_backed_up: bool
|
||||||
backup_description: str
|
backup_description: str
|
||||||
status: ServiceStatusEnum
|
status: ServiceStatusEnum
|
||||||
|
@ -232,6 +233,7 @@ def service_to_graphql_service(service: ServiceInterface) -> Service:
|
||||||
is_movable=service.is_movable(),
|
is_movable=service.is_movable(),
|
||||||
is_required=service.is_required(),
|
is_required=service.is_required(),
|
||||||
is_enabled=service.is_enabled(),
|
is_enabled=service.is_enabled(),
|
||||||
|
is_installed=service.is_installed(),
|
||||||
can_be_backed_up=service.can_be_backed_up(),
|
can_be_backed_up=service.can_be_backed_up(),
|
||||||
backup_description=service.get_backup_description(),
|
backup_description=service.get_backup_description(),
|
||||||
status=ServiceStatusEnum(service.get_status().value),
|
status=ServiceStatusEnum(service.get_status().value),
|
||||||
|
|
|
@ -146,6 +146,16 @@ class Service(ABC):
|
||||||
with ReadUserData() as user_data:
|
with ReadUserData() as user_data:
|
||||||
return user_data.get("modules", {}).get(name, {}).get("enable", False)
|
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
|
@staticmethod
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_status() -> ServiceStatus:
|
def get_status() -> ServiceStatus:
|
||||||
|
|
Loading…
Reference in a new issue