Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add other absence #292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pronotepy/dataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,21 @@ def __init__(self, json_dict: dict) -> None:

del self._resolver

class OtherAbsence(Object):
"""
Represents a absence with a given period. You shouldn't have to create this class manually.

Attributes:
id (str): the id of the absence (used internally)
name (str): the justification for the absence
"""

def __init__(self, json_dict: dict) -> None:
super().__init__(json_dict)
self.id: str = self._resolver(str, "N")
self.name: str = self._resolver(str, "L")

del self._resolver

class Period(Object):
"""
Expand Down Expand Up @@ -638,6 +653,21 @@ def punishments(self) -> List[Punishment]:
absences = response["donneesSec"]["data"]["listeAbsences"]["V"]
return [Punishment(self._client, a) for a in absences if a["G"] == 41]

@property
def otherabsences(self) -> List[OtherAbsence]:
"""
All "Other Absences" from a given period, not yet classified. I found type 46 for a forgotten notebook.
"""
json_data = {
"periode": {"N": self.id, "L": self.name, "G": 2},
"DateDebut": {"_T": 7, "V": self.start.strftime("%d/%m/%Y %H:%M:%S")},
"DateFin": {"_T": 7, "V": self.end.strftime("%d/%m/%Y %H:%M:%S")},
}

response = self._client.post("PagePresence", 19, json_data)
absences = response["donneesSec"]["data"]["listeAbsences"]["V"]
return [OtherAbsence(a) for a in absences if a["G"] == 46 ]


class Average(Object):
"""
Expand Down