Coverage for src/kwai/modules/training/trainings/training_definition.py: 100%
54 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 training definition entity."""
3from kwai.core.domain.entity import Entity
4from kwai.core.domain.value_objects.identifier import IntIdentifier
5from kwai.core.domain.value_objects.owner import Owner
6from kwai.core.domain.value_objects.time_period import TimePeriod
7from kwai.core.domain.value_objects.traceable_time import TraceableTime
8from kwai.core.domain.value_objects.weekday import Weekday
9from kwai.modules.training.teams.team import TeamEntity
12TrainingDefinitionIdentifier = IntIdentifier
15class TrainingDefinitionEntity(Entity[TrainingDefinitionIdentifier]):
16 """A training definition entity.
18 A training definition can be used to create recurring trainings.
19 """
21 def __init__(
22 self,
23 *,
24 id_: TrainingDefinitionIdentifier | None = None,
25 name: str,
26 description: str,
27 weekday: Weekday,
28 period: TimePeriod,
29 active: bool = True,
30 location: str = "",
31 remark: str = "",
32 team: TeamEntity | None = None,
33 owner: Owner,
34 traceable_time: TraceableTime | None = None,
35 ):
36 """Initialize a training definition.
38 Args:
39 id_: The id of the training definition.
40 name: The name of the training definition.
41 description: A description of the training definition.
42 weekday: The weekday to use to create the recurring trainings.
43 period: The time period to use to create the recurring trainings.
44 active: Is this definition active?
45 location: The location of the recurring trainings.
46 remark: A remark about this training definition.
47 team: A team that is associated with the definition.
48 owner: The owner of this training definition.
49 traceable_time: The creation and modification timestamp of the definition.
50 """
51 super().__init__(id_ or TrainingDefinitionIdentifier())
52 self._name = name
53 self._description = description
54 self._weekday = weekday
55 self._period = period
56 self._active = active
57 self._location = location
58 self._remark = remark
59 self._team = team
60 self._owner = owner
61 self._traceable_time = traceable_time or TraceableTime()
63 @property
64 def id(self) -> TrainingDefinitionIdentifier:
65 """Return the id of the training definition."""
66 return self._id
68 @property
69 def name(self) -> str:
70 """Return the name of the training definition."""
71 return self._name
73 @property
74 def description(self) -> str:
75 """Return the description of the training definition."""
76 return self._description
78 @property
79 def weekday(self) -> Weekday:
80 """Return the weekday of the training definition."""
81 return self._weekday
83 @property
84 def period(self) -> TimePeriod:
85 """Return the period of the training definition."""
86 return self._period
88 @property
89 def active(self) -> bool:
90 """Return True when the training definition is active."""
91 return self._active
93 @property
94 def location(self) -> str:
95 """Return the location of the training definition."""
96 return self._location
98 @property
99 def owner(self) -> Owner:
100 """Return the owner of the training definition."""
101 return self._owner
103 @property
104 def remark(self) -> str:
105 """Return the remark of the training definition."""
106 return self._remark
108 @property
109 def traceable_time(self) -> TraceableTime:
110 """Return the creation/modification timestamp of this training definition."""
111 return self._traceable_time
113 @property
114 def team(self) -> TeamEntity:
115 """Return the team that is associated with this definition."""
116 return self._team