Coverage for src/kwai/modules/portal/pages/page.py: 100%
33 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module that defines the Page entity."""
3from kwai.core.domain.entity import Entity
4from kwai.core.domain.value_objects.identifier import IntIdentifier
5from kwai.core.domain.value_objects.text import LocaleText
6from kwai.core.domain.value_objects.traceable_time import TraceableTime
7from kwai.modules.portal.applications.application import ApplicationEntity
10PageIdentifier = IntIdentifier
13class PageEntity(Entity[PageIdentifier]):
14 """A page entity."""
16 def __init__(
17 self,
18 *,
19 id_: PageIdentifier | None = None,
20 enabled: bool = False,
21 application: ApplicationEntity,
22 texts: list[LocaleText],
23 priority: int,
24 remark: str,
25 traceable_time: TraceableTime | None = None,
26 ):
27 """Initialize a page entity.
29 Args:
30 id_: The id of the page.
31 enabled: Is this page enabled?
32 application: The related application.
33 texts: The text content of the page.
34 priority: The priority level of the page.
35 remark: A remark about the page.
36 traceable_time: The create and update time of the page.
37 """
38 super().__init__(id_ or PageIdentifier())
39 self._enabled = enabled
40 self._application = application
41 self._texts = texts
42 self._priority = priority
43 self._remark = remark
44 self._traceable_time = traceable_time or TraceableTime()
46 @property
47 def enabled(self) -> bool:
48 """Return if the page is enabled."""
49 return self._enabled
51 @property
52 def priority(self) -> int:
53 """Return the priority of the page."""
54 return self._priority
56 @property
57 def remark(self) -> str:
58 """Return the remark."""
59 return self._remark
61 @property
62 def texts(self) -> list[LocaleText]:
63 """Return the content."""
64 return self._texts.copy()
66 @property
67 def traceable_time(self) -> TraceableTime:
68 """Return the created_at."""
69 return self._traceable_time
71 @property
72 def application(self) -> ApplicationEntity:
73 """Return the application."""
74 return self._application