Coverage for bc/kwai-bc-portal/src/kwai_bc_portal/domain/application.py: 100%
23 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
1"""Module that defines an application entity."""
3from dataclasses import dataclass
4from typing import ClassVar, Type
6from kwai_core.domain.entity import DataclassEntity
7from kwai_core.domain.value_objects.identifier import IntIdentifier
10class ApplicationIdentifier(IntIdentifier):
11 """Identifier for an application."""
14@dataclass(kw_only=True, eq=False, slots=True, frozen=True)
15class ApplicationEntity(DataclassEntity):
16 """An application entity.
18 Attributes:
19 title: The title of the application
20 name: A unique name for the application
21 short_description: A short description for the application
22 description: A long description for the application
23 remark: A remark for the application
24 news: Can this application contain news?
25 pages: Can this application contain pages?
26 events: Can this application contain events?
27 weight: A weight, can be used to order applications.
28 """
30 ID: ClassVar[Type] = ApplicationIdentifier
32 title: str
33 name: str
34 short_description: str
35 description: str = ""
36 remark: str = ""
37 news: bool = True
38 pages: bool = True
39 events: bool = True
40 weight: int = 0
42 @property
43 def can_contain_news(self) -> bool:
44 """Return True when the application can contain news."""
45 return self.news
47 @property
48 def can_contain_pages(self) -> bool:
49 """Return True when the application can contain pages."""
50 return self.pages
52 @property
53 def can_contain_events(self) -> bool:
54 """Return True when the application can contain events."""
55 return self.events