Coverage for kwai/modules/training/trainings/training_definition.py: 100%

49 statements  

« prev     ^ index     » next       coverage.py v7.3.0, created at 2023-09-05 17:55 +0000

1"""Module for defining a training definition entity.""" 

2from kwai.core.domain.entity import Entity 

3from kwai.core.domain.value_objects.identifier import IntIdentifier 

4from kwai.core.domain.value_objects.owner import Owner 

5from kwai.core.domain.value_objects.time_period import TimePeriod 

6from kwai.core.domain.value_objects.traceable_time import TraceableTime 

7from kwai.core.domain.value_objects.weekday import Weekday 

8 

9TrainingDefinitionIdentifier = IntIdentifier 

10 

11 

12class TrainingDefinitionEntity(Entity[TrainingDefinitionIdentifier]): 

13 """A training definition entity. 

14 

15 A training definition can be used to create recurring trainings. 

16 """ 

17 

18 def __init__( 

19 self, 

20 *, 

21 id_: TrainingDefinitionIdentifier | None = None, 

22 name: str, 

23 description: str, 

24 weekday: Weekday, 

25 period: TimePeriod, 

26 active: bool = True, 

27 location: str = "", 

28 remark: str = "", 

29 owner: Owner, 

30 traceable_time: TraceableTime | None = None 

31 ): 

32 """Initialize a training definition. 

33 

34 Args: 

35 id_: The id of the training definition. 

36 name: The name of the training definition. 

37 description: A description of the training definition. 

38 weekday: The weekday to use to create the recurring trainings. 

39 period: The time period to use to create the recurring trainings. 

40 active: Is this definition active? 

41 location: The location of the recurring trainings. 

42 remark: A remark about this training definition. 

43 owner: The owner of this training definition. 

44 traceable_time: The creation and modification timestamp of the definition. 

45 """ 

46 super().__init__(id_ or TrainingDefinitionIdentifier()) 

47 self._name = name 

48 self._description = description 

49 self._weekday = weekday 

50 self._period = period 

51 self._active = active 

52 self._location = location 

53 self._remark = remark 

54 self._owner = owner 

55 self._traceable_time = traceable_time or TraceableTime() 

56 

57 @property 

58 def id(self) -> TrainingDefinitionIdentifier: 

59 """Return the id of the training definition.""" 

60 return self._id 

61 

62 @property 

63 def name(self) -> str: 

64 """Return the name of the training definition.""" 

65 return self._name 

66 

67 @property 

68 def description(self) -> str: 

69 """Return the description of the training definition.""" 

70 return self._description 

71 

72 @property 

73 def weekday(self) -> Weekday: 

74 """Return the weekday of the training definition.""" 

75 return self._weekday 

76 

77 @property 

78 def period(self) -> TimePeriod: 

79 """Return the period of the training definition.""" 

80 return self._period 

81 

82 @property 

83 def active(self) -> bool: 

84 """Return True when the training definition is active.""" 

85 return self._active 

86 

87 @property 

88 def location(self) -> str: 

89 """Return the location of the training definition.""" 

90 return self._location 

91 

92 @property 

93 def owner(self) -> Owner: 

94 """Return the owner of the training definition.""" 

95 return self._owner 

96 

97 @property 

98 def remark(self) -> str: 

99 """Return the remark of the training definition.""" 

100 return self._remark 

101 

102 @property 

103 def traceable_time(self) -> TraceableTime: 

104 """Return the creation/modification timestamp of this training definition.""" 

105 return self._traceable_time