FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

new: class_reg_events · robquant/python-webuntis@67adf9b · GitHub

Commit 67adf9b

Browse files
committed
new: class_reg_events
1 parent 7791fbf commit 67adf9b

3 files changed

Lines changed: 111 additions & 0 deletions

File tree

‎webuntis/objects.py‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,3 +924,56 @@ def __init__(self, data, parent=None, session=None):
924924
# the data is a dict() with just one key
925925
data = data[u'periodsWithAbsences']
926926
Result.__init__(self, data, parent, session)
927+
928+
929+
class ClassRegEvent(Result):
930+
"""Represents an ClassRegEvent."""
931+
932+
@lazyproperty
933+
def student(self):
934+
"""
935+
doku says: student ID, but it is the students KEY
936+
937+
:return:
938+
"""
939+
return self._session.students(from_cache=True).filter(key=self._data[u'studentid'])[0]
940+
941+
@lazyproperty
942+
def sur_name(self):
943+
"""sur name of the person"""
944+
return self._data[u'surname']
945+
946+
@lazyproperty
947+
def fore_name(self):
948+
"""fore name of the person"""
949+
return self._data[u'forname']
950+
951+
@lazyproperty
952+
def name(self):
953+
"""fore name of the person"""
954+
return " ".join((self.sur_name, self.fore_name))
955+
956+
@lazyproperty
957+
def reason(self):
958+
"""reason of the classregevent"""
959+
return self._data[u'reason']
960+
961+
@lazyproperty
962+
def text(self):
963+
"""text of the classregevent"""
964+
return self._data[u'text']
965+
966+
@lazyproperty
967+
def date(self):
968+
"""the date of the classregevent."""
969+
return datetime_utils.parse_date(self._data[u'date'])
970+
971+
@lazyproperty
972+
def subject(self):
973+
"""the subject of the classregevent."""
974+
return self._data[u'subject']
975+
976+
977+
class ClassRegEventList(ListResult):
978+
"""A list of ClassRegEvents."""
979+
_itemclass = ClassRegEvent

‎webuntis/objects.pyi‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,3 +527,47 @@ class AbsencesList(ListResult):
527527

528528
def __getitem__(self, i: int) -> AbsenceObject:
529529
...
530+
531+
532+
class ClassRegEvent(Result):
533+
@property
534+
def student(self) -> StudentObject:
535+
...
536+
537+
@property
538+
def sur_name(self) -> str:
539+
...
540+
541+
@property
542+
def fore_name(self) -> str:
543+
...
544+
545+
@property
546+
def name(self) -> str:
547+
...
548+
549+
@property
550+
def reason(self) -> str:
551+
...
552+
553+
@property
554+
def text(self) -> str:
555+
...
556+
557+
@property
558+
def date(self) -> date:
559+
...
560+
561+
@property
562+
def subject(self) -> str:
563+
...
564+
565+
566+
class ClassRegEventList(ListResult):
567+
_itemclass = ClassRegEvent
568+
569+
def filter(self, **criterions) -> ClassRegEventList:
570+
...
571+
572+
def __getitem__(self, i: int) -> ClassRegEvent:
573+
...

‎webuntis/session.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,20 @@ def timetable_with_absences(self, start, end):
350350

351351
return objects.AbsencesList, 'getTimetableWithAbsences', parameters
352352

353+
@result_wrapper
354+
def class_reg_events(self, start, end):
355+
"""Information about the ClassRegEvents
356+
:type start: :py:class:`datetime.datetime` or :py:class:`datetime.date` or int
357+
:param start: The beginning of the time period.
358+
359+
:type end: :py:class:`datetime.datetime` or :py:class:`datetime.date` or int
360+
:param end: The end of the time period.
361+
362+
:rtype: :py:class:`webuntis.objects.ClassRegEventList`
363+
"""
364+
parameters = self._create_date_param(end, start)
365+
return objects.ClassRegEventList, 'getClassregEvents', parameters
366+
353367
@staticmethod
354368
def _create_date_param(end, start, **kwargs):
355369
json_start = utils.datetime_utils.format_date(start)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL