| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -351,7 +351,7 @@ class StubSession(object): | |||
| 351 | 351 | session=sess | |
| 352 | 352 | ) | |
| 353 | 353 | student1 = webuntis.objects.StudentObject( | |
| 354 | - data={u'id': 9, u'name': u'Potter', u'longName': u'Potter', u'foreName': 'Harry', u'key': 42}, | ||
| 354 | + data={u'id': 9, u'name': u'Potter', u'longName': u'Potter', u'foreName': 'Harry', u'key': '42'}, | ||
| 355 | 355 | session=sess | |
| 356 | 356 | ) | |
| 357 | 357 | ||
@@ -609,7 +609,7 @@ def testExamObject(self): | |||
| 609 | 609 | assert ex.klassen[0].name == u'1A' | |
| 610 | 610 | assert len(ex.students) == 1 | |
| 611 | 611 | assert ex.students[0].name == u'Potter' | |
| 612 | - assert ex.students[0].key == 42 | ||
| 612 | + assert ex.students[0].key == '42' | ||
| 613 | 613 | ||
| 614 | 614 | def testExamList(selfself): | |
| 615 | 615 | exl = webuntis.objects.ExamsList( | |
@@ -626,10 +626,10 @@ class AbsencesTests(WebUntisTestCase): | |||
| 626 | 626 | def testAbsence(self): | |
| 627 | 627 | ab = webuntis.objects.AbsenceObject( | |
| 628 | 628 | data={'date': 20180320, 'startTime': 850, 'endTime': 940, | |
| 629 | - 'studentId': '9', | ||
| 629 | + 'studentId': '42', # <- key! | ||
| 630 | 630 | 'subjectId': '4', | |
| 631 | 631 | 'teacherIds': ['3', '7'], | |
| 632 | - 'student_group': u'MAM_1A_M', | ||
| 632 | + 'studentGroup': u'MAM_1A_M', | ||
| 633 | 633 | 'user': '', | |
| 634 | 634 | 'checked': True}, | |
| 635 | 635 | session=StubSession() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -834,11 +834,19 @@ class ExamsList(ListResult): | |||
| 834 | 834 | ||
| 835 | 835 | ||
| 836 | 836 | class AbsenceObject(Result): | |
| 837 | - """Represents an absence.""" | ||
| 837 | + """Represents an absence. | ||
| 838 | + | ||
| 839 | + Attention: if there are multiple teachers/groups at the same time -> multiple entries for the | ||
| 840 | + same student, but the absentTime is only set for one (the first?) entry. | ||
| 841 | + """ | ||
| 838 | 842 | ||
| 839 | 843 | @lazyproperty | |
| 840 | 844 | def student(self): | |
| 841 | - return self._session.students(from_cache=True).filter(id=int(self._data[u'studentId']))[0] | ||
| 845 | + """ | ||
| 846 | + doku says: student ID, but it is the students KEY | ||
| 847 | + :return: | ||
| 848 | + """ | ||
| 849 | + return self._session.students(from_cache=True).filter(key=self._data[u'studentId'])[0] | ||
| 842 | 850 | ||
| 843 | 851 | @lazyproperty | |
| 844 | 852 | def subject(self): | |
@@ -861,7 +869,10 @@ def teachers(self): | |||
| 861 | 869 | ||
| 862 | 870 | @lazyproperty | |
| 863 | 871 | def student_group(self): | |
| 864 | - return self._data[u'student_group'] | ||
| 872 | + try: | ||
| 873 | + return self._data[u'studentGroup'] | ||
| 874 | + except KeyError: | ||
| 875 | + return '' | ||
| 865 | 876 | ||
| 866 | 877 | @lazyproperty | |
| 867 | 878 | def checked(self): | |
@@ -890,6 +901,20 @@ def end(self): | |||
| 890 | 901 | self._data[u'endTime'] | |
| 891 | 902 | ) | |
| 892 | 903 | ||
| 904 | + @lazyproperty | ||
| 905 | + def reason(self): | ||
| 906 | + try: | ||
| 907 | + return self._data[u'absenceReason'] | ||
| 908 | + except KeyError: | ||
| 909 | + return '' | ||
| 910 | + | ||
| 911 | + @lazyproperty | ||
| 912 | + def time(self): | ||
| 913 | + try: | ||
| 914 | + return int(self._data[u'absentTime']) | ||
| 915 | + except KeyError: | ||
| 916 | + return 0 | ||
| 917 | + | ||
| 893 | 918 | ||
| 894 | 919 | class AbsencesList(ListResult): | |
| 895 | 920 | """A list of absences.""" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -196,6 +196,7 @@ class PeriodList(ListResult): | |||
| 196 | 196 | def combine(self) -> PeriodList: | |
| 197 | 197 | ... | |
| 198 | 198 | ||
| 199 | + | ||
| 199 | 200 | class PersonObject(ListItem): | |
| 200 | 201 | ||
| 201 | 202 | @property | |
@@ -352,6 +353,7 @@ class SubstitutionList(ListResult): | |||
| 352 | 353 | def combine(self) -> SubstitutionList: | |
| 353 | 354 | ... | |
| 354 | 355 | ||
| 356 | + | ||
| 355 | 357 | class TeacherObject(PersonObject): | |
| 356 | 358 | @property | |
| 357 | 359 | def title(self) -> str: | |
@@ -468,6 +470,7 @@ class ExamObject(Result): | |||
| 468 | 470 | def students(self) -> StudentsList: | |
| 469 | 471 | ... | |
| 470 | 472 | ||
| 473 | + | ||
| 471 | 474 | class ExamsList(ListResult): | |
| 472 | 475 | _itemclass = ExamObject | |
| 473 | 476 | ||
@@ -507,6 +510,14 @@ class AbsenceObject(Result): | |||
| 507 | 510 | def checked(self) -> bool: | |
| 508 | 511 | ... | |
| 509 | 512 | ||
| 513 | + @property | ||
| 514 | + def reason(self) -> str: | ||
| 515 | + ... | ||
| 516 | + | ||
| 517 | + @property | ||
| 518 | + def time(self) -> int: | ||
| 519 | + ... | ||
| 520 | + | ||
| 510 | 521 | ||
| 511 | 522 | class AbsencesList(ListResult): | |
| 512 | 523 | _itemclass = AbsenceObject | |
| Back | FazBrowse Home | New Git URL |
0 commit comments