Skip to content

Commit b7b3a09

Browse files
committed
add other absence
1 parent 5d09a86 commit b7b3a09

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

pronotepy/dataClasses.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,21 @@ def __init__(self, json_dict: dict) -> None:
475475

476476
del self._resolver
477477

478+
class OtherAbsence(Object):
479+
"""
480+
Represents a absence with a given period. You shouldn't have to create this class manually.
481+
482+
Attributes:
483+
id (str): the id of the absence (used internally)
484+
name (str): the justification for the absence
485+
"""
486+
487+
def __init__(self, json_dict: dict) -> None:
488+
super().__init__(json_dict)
489+
self.id: str = self._resolver(str, "N")
490+
self.name: str = self._resolver(str, "L")
491+
492+
del self._resolver
478493

479494
class Period(Object):
480495
"""
@@ -640,6 +655,21 @@ def punishments(self) -> List[Punishment]:
640655
absences = response["donneesSec"]["donnees"]["listeAbsences"]["V"]
641656
return [Punishment(self._client, a) for a in absences if a["G"] == 41]
642657

658+
@property
659+
def otherabsences(self) -> List[OtherAbsence]:
660+
"""
661+
All "Other Absences" from a given period, not yet classified. I found type 46 for a forgotten notebook.
662+
"""
663+
json_data = {
664+
"periode": {"N": self.id, "L": self.name, "G": 2},
665+
"DateDebut": {"_T": 7, "V": self.start.strftime("%d/%m/%Y %H:%M:%S")},
666+
"DateFin": {"_T": 7, "V": self.end.strftime("%d/%m/%Y %H:%M:%S")},
667+
}
668+
669+
response = self._client.post("PagePresence", 19, json_data)
670+
absences = response["donneesSec"]["donnees"]["listeAbsences"]["V"]
671+
return [OtherAbsence(a) for a in absences if a["G"] == 46 ]
672+
643673

644674
class Average(Object):
645675
"""

0 commit comments

Comments
 (0)