Coverage for src/kwai/modules/club/domain/member.py: 100%

42 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2024-01-01 00:00 +0000

1"""Module for defining the Member entity.""" 

2 

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.traceable_time import TraceableTime 

7from kwai.core.domain.value_objects.unique_id import UniqueId 

8from kwai.modules.club.domain.person import PersonEntity 

9from kwai.modules.club.domain.value_objects import License 

10 

11 

12MemberIdentifier = IntIdentifier 

13 

14 

15class MemberEntity(Entity[MemberIdentifier]): 

16 """A member entity.""" 

17 

18 def __init__( 

19 self, 

20 *, 

21 id_: MemberIdentifier | None = None, 

22 uuid: UniqueId | None = None, 

23 license: License, 

24 person: PersonEntity, 

25 remark: str = "", 

26 active: bool = True, 

27 competition: bool = False, 

28 traceable_time: TraceableTime | None = None, 

29 ): 

30 """Initialize a member. 

31 

32 Args: 

33 id_: The id of the member. 

34 uuid: A unique id for the member. 

35 license: The license of the member. 

36 person: The related person entity. 

37 remark: A remark about the member. 

38 active: Is this member still member of the club? 

39 competition: Is this member participating in competitions? 

40 traceable_time: The creation and modification timestamp of the training. 

41 """ 

42 super().__init__(id_ or MemberIdentifier()) 

43 self._uuid = uuid or UniqueId.generate() 

44 self._license = license 

45 self._person = person 

46 self._remark = remark 

47 self._active = active 

48 self._competition = competition 

49 self._traceable_time = traceable_time or TraceableTime() 

50 

51 @property 

52 def is_active(self) -> bool: 

53 """Is this member active?""" 

54 return self._active 

55 

56 @property 

57 def is_competitive(self) -> bool: 

58 """Is this member participating in competition?""" 

59 return self._competition 

60 

61 @property 

62 def license(self) -> License: 

63 """Return the license.""" 

64 return self._license 

65 

66 @property 

67 def name(self) -> Name: 

68 """Return the name of the member.""" 

69 return self.person.name 

70 

71 @property 

72 def person(self) -> PersonEntity: 

73 """Return the person.""" 

74 return self._person 

75 

76 @property 

77 def traceable_time(self) -> TraceableTime: 

78 """Return the traceable_time.""" 

79 return self._traceable_time 

80 

81 @property 

82 def remark(self) -> str: 

83 """Return the remark.""" 

84 return self._remark 

85 

86 @property 

87 def uuid(self) -> UniqueId: 

88 """Return the uuid.""" 

89 return self._uuid