Coverage for src/kwai/modules/club/domain/coach.py: 98%
44 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 for defining a coach entity."""
3from kwai.core.domain.entity import Entity
4from kwai.core.domain.value_objects.identifier import IntIdentifier
5from kwai.core.domain.value_objects.name import Name
6from kwai.core.domain.value_objects.owner import Owner
7from kwai.core.domain.value_objects.traceable_time import TraceableTime
8from kwai.modules.club.domain.member import MemberEntity
11CoachIdentifier = IntIdentifier
14class CoachEntity(Entity[CoachIdentifier]):
15 """A coach entity."""
17 def __init__(
18 self,
19 *,
20 id_: CoachIdentifier | None = None,
21 member: MemberEntity,
22 description: str = "",
23 diploma: str = "",
24 active: bool = True,
25 remark: str = "",
26 user: Owner | None = None,
27 traceable_time: TraceableTime | None = None,
28 ):
29 """Initialize a coach.
31 Args:
32 id_ (CoachIdentifier): The id of the coach.
33 member: A coach is a member of the club.
34 description: The description (bio) of the coach.
35 diploma: The diploma of the coach.
36 active: Whether the coach is active.
37 remark: A remark about the coach.
38 user: A coach can also be a user of the system.
39 traceable_time: The creation and modification timestamp of the coach.
40 """
41 super().__init__(id_ or CoachIdentifier())
42 self._member = member
43 self._description = description
44 self._diploma = diploma
45 self._active = active
46 self._remark = remark
47 self._user = user
48 self._traceable_time = traceable_time or TraceableTime()
50 @property
51 def is_active(self) -> bool:
52 """Is the coach active?"""
53 return self._active
55 @property
56 def member(self) -> MemberEntity:
57 """Return the related member."""
58 return self._member
60 @property
61 def name(self) -> Name:
62 """Return the name of the coach."""
63 return self._member.person.name
65 @property
66 def diploma(self) -> str:
67 """Return the diploma of the coach."""
68 return self._diploma
70 @property
71 def description(self) -> str:
72 """Return the description of the coach."""
73 return self._description
75 @property
76 def remark(self) -> str:
77 """Return the remark of the coach."""
78 return self._remark
80 @property
81 def traceable_time(self) -> TraceableTime:
82 """Return the traceable_time."""
83 return self._traceable_time
85 @property
86 def uuid(self):
87 """Return the uuid of the coach."""
88 return self._member.uuid
90 @property
91 def user(self) -> Owner | None:
92 """Return the related user."""
93 return self._user