Coverage for kwai/modules/training/trainings/training.py: 100%
56 statements
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
1"""Module for defining a training entity."""
2from kwai.core.domain.entity import Entity
3from kwai.core.domain.value_objects.identifier import IntIdentifier
4from kwai.core.domain.value_objects.period import Period
5from kwai.core.domain.value_objects.text import LocaleText
6from kwai.core.domain.value_objects.traceable_time import TraceableTime
7from kwai.modules.training.teams.team import TeamEntity
8from kwai.modules.training.trainings.training_definition import (
9 TrainingDefinitionEntity,
10)
11from kwai.modules.training.trainings.value_objects import TrainingCoach
13TrainingIdentifier = IntIdentifier
16class TrainingEntity(Entity[TrainingIdentifier]):
17 """A training entity."""
19 def __init__(
20 self,
21 *,
22 id_: TrainingIdentifier | None = None,
23 content: list[LocaleText],
24 definition: TrainingDefinitionEntity | None = None,
25 coaches: list[TrainingCoach] | None = None,
26 teams: list[TeamEntity] | None = None,
27 season: None = None,
28 period: Period,
29 active: bool = True,
30 cancelled: bool = False,
31 location: str = "",
32 remark: str = "",
33 traceable_time: TraceableTime | None = None,
34 ):
35 """Initialize a training.
37 Args:
38 id_: The id of the training
39 content: A list with text content
40 definition: The related definition, when the training was created from a
41 definition.
42 coaches: A list of assigned coaches.
43 teams: A list of assigned teams.
44 period: The period of the training.
45 season: The season that the training belongs to (not supported yet).
46 active: Is this training active?
47 cancelled: Is this training cancelled?
48 location: The location of this training
49 remark: A remark about this training
50 traceable_time: The creation and modification timestamp of the training.
51 """
52 super().__init__(id_ or TrainingIdentifier())
53 self._content = content
54 self._definition = definition
55 self._coaches = coaches or []
56 self._teams = teams or []
57 self._season = season
58 self._period = period
59 self._active = active
60 self._cancelled = cancelled
61 self._location = location
62 self._remark = remark
63 self._traceable_time = traceable_time or TraceableTime()
65 @property
66 def id(self) -> TrainingIdentifier:
67 """Return the id of the training."""
68 return self._id
70 @property
71 def definition(self) -> TrainingDefinitionEntity | None:
72 """Return the related training definition."""
73 return self._definition
75 @property
76 def content(self) -> list[LocaleText]:
77 """Return the text content of a training.
79 Remark:
80 The list is a copy.
81 """
82 return self._content.copy()
84 @property
85 def coaches(self) -> list[TrainingCoach]:
86 """Return the coaches attached to the training.
88 Remark:
89 The list is a copy
90 """
91 return self._coaches.copy()
93 @property
94 def teams(self) -> list[TeamEntity]:
95 """Return the teams of the training.
97 Remark:
98 The list is a copy
99 """
100 return self._teams.copy()
102 @property
103 def traceable_time(self) -> TraceableTime:
104 """Return the traceable time of the training."""
105 return self._traceable_time
107 @property
108 def period(self) -> Period:
109 """Return the period of the training."""
110 return self._period
112 @property
113 def active(self) -> bool:
114 """Return if the training is active or not."""
115 return self._active
117 @property
118 def cancelled(self) -> bool:
119 """Return if the training is cancelled or not."""
120 return self._cancelled
122 @property
123 def location(self) -> str:
124 """Return the location of the training."""
125 return self._location
127 @property
128 def remark(self) -> str | None:
129 """Return the remark."""
130 return self._remark