Coverage for src/kwai/modules/portal/applications/application.py: 100%
50 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 an application entity."""
3from kwai.core.domain.entity import Entity
4from kwai.core.domain.value_objects.identifier import IntIdentifier
5from kwai.core.domain.value_objects.traceable_time import TraceableTime
8ApplicationIdentifier = IntIdentifier
11class ApplicationEntity(Entity[ApplicationIdentifier]):
12 """An application entity."""
14 def __init__(
15 self,
16 *,
17 id_: ApplicationIdentifier | None = None,
18 title: str,
19 name: str,
20 short_description: str,
21 description: str = "",
22 remark: str = "",
23 news: bool = True,
24 pages: bool = True,
25 events: bool = True,
26 weight: int = 0,
27 traceable_time: TraceableTime | None = None,
28 ):
29 """Initialize the application.
31 Args:
32 id_: The id of the application entity
33 title: The title of the application
34 name: A unique name for the application
35 short_description: A short description for the application
36 description: A long description for the application
37 remark: A remark for the application
38 news: Can this application contain news?
39 pages: Can this application contain pages?
40 events: Can this application contain events?
41 weight: A weight, can be used to order applications.
42 traceable_time: The creation and modification timestamp of the application.
43 """
44 super().__init__(id_ or ApplicationIdentifier())
45 self._title = title
46 self._name = name
47 self._short_description = short_description
48 self._description = description
49 self._remark = remark
50 self._news = news
51 self._pages = pages
52 self._events = events
53 self._weight = weight
54 self._traceable_time = traceable_time or TraceableTime()
56 @property
57 def id(self) -> ApplicationIdentifier:
58 """Return the id."""
59 return self._id
61 @property
62 def title(self) -> str:
63 """Return the title."""
64 return self._title
66 @property
67 def name(self) -> str:
68 """Return the name."""
69 return self._name
71 @property
72 def short_description(self) -> str:
73 """Return the short description."""
74 return self._short_description
76 @property
77 def description(self) -> str:
78 """Return the description."""
79 return self._description
81 @property
82 def remark(self) -> str:
83 """Return the remark."""
84 return self._remark
86 @property
87 def can_contain_news(self) -> bool:
88 """Return True when the application can contain news."""
89 return self._news
91 @property
92 def can_contain_pages(self) -> bool:
93 """Return True when the application can contain pages."""
94 return self._pages
96 @property
97 def can_contain_events(self) -> bool:
98 """Return True when the application can contain events."""
99 return self._events
101 @property
102 def weight(self) -> int:
103 """Return the weight."""
104 return self._weight
106 @property
107 def traceable_time(self) -> TraceableTime:
108 """Return the creation/modification timestamp of this application."""
109 return self._traceable_time