Coverage for src/kwai/modules/teams/domain/team_member.py: 96%
49 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 the team member entity."""
3from dataclasses import dataclass
5from kwai.core.domain.entity import Entity
6from kwai.core.domain.value_objects.identifier import IntIdentifier
7from kwai.core.domain.value_objects.name import Name
8from kwai.core.domain.value_objects.traceable_time import TraceableTime
9from kwai.core.domain.value_objects.unique_id import UniqueId
10from kwai.modules.club.domain.country import CountryEntity
11from kwai.modules.club.domain.value_objects import Birthdate, Gender, License
14MemberIdentifier = IntIdentifier
17class MemberEntity(Entity[MemberIdentifier]):
18 """A member entity.
20 A member entity is an entity which holds specific information of a member
21 that can be used for a member of a team.
22 """
24 def __init__(
25 self,
26 *,
27 id_: MemberIdentifier,
28 uuid: UniqueId,
29 name: Name,
30 license: License,
31 birthdate: Birthdate,
32 nationality: CountryEntity,
33 gender: Gender,
34 active_in_club: bool = True,
35 ):
36 super().__init__(id_)
37 self._name = name
38 self._uuid = uuid
39 self._license = license
40 self._birthdate = birthdate
41 self._nationality = nationality
42 self._gender = gender
43 self._active_in_club = active_in_club
45 def __str__(self) -> str:
46 """Return a string of this entity."""
47 return f"{self._uuid} - {self._name}"
49 def __repr__(self) -> str:
50 """Return a representation of this entity."""
51 return f"<{self.__class__.__name__} id={self.id}, uuid={self.uuid}, name={self.name}>"
53 @property
54 def name(self) -> Name:
55 """Return the name."""
56 return self._name
58 @property
59 def uuid(self) -> UniqueId:
60 """Return the uuid."""
61 return self._uuid
63 @property
64 def license(self) -> License:
65 """Return the license."""
66 return self._license
68 @property
69 def birthdate(self) -> Birthdate:
70 """Return the birthdate."""
71 return self._birthdate
73 @property
74 def nationality(self) -> CountryEntity:
75 """Return the nat."""
76 return self._nationality
78 @property
79 def gender(self) -> Gender:
80 """Return the gender."""
81 return self._gender
83 @property
84 def is_active_in_club(self) -> bool:
85 """Return if the member is active."""
86 return self._active_in_club
89@dataclass(kw_only=True, frozen=True, slots=True)
90class TeamMember:
91 """Represent a member of a team.
93 When active is False, it means the member is not active for the team it belongs
94 to.
95 """
97 active: bool = False
98 member: MemberEntity
99 traceable_time: TraceableTime = TraceableTime()