Repository navigation
Return the child's timetable from get_my_timetable() for parents - #129
Conversation
…pageAPI#81) A parent account has no timetable of its own, EduPage answers the loadData request with a page reload, and get_my_timetable() failed with IndexError. When no child is selected and the parent has exactly one child, use that child's timetable. Otherwise raise MissingDataException asking to call switch_to_child(), and raise it instead of IndexError for any other unexpected response. Co-Authored-By: Claude Code
|
I had a hard time deciding what to do here. Auto-selecting the only child is convenient, but that only fixes I'd rather "create" a new (unwritten) rule for every method that is broken for parents: call A parent account with no selected child now gets For a parent with one child, correct usage is: from datetime import date
from edupage_api import Edupage
edupage = Edupage()
edupage.login("username", "password", "subdomain")
child_id = edupage.data["parentStudentids"][0]
edupage.switch_to_child(child_id)
timetable = edupage.get_my_timetable(date.today())When writing the example, I realized there is no way to easily get a list of your own children (as a parent). That is what I'll try to handle next to improve the experience. Thank you for your contribution! |
Problem
Same traceback as #81. With a parent account,
get_my_timetable()fails in__get_date_plan:A parent (
Rodic-…) has no timetable of their own. Without a child selected, EduPage answers theloadDatagcall with only:so the
Rodic-…",marker the code splits on isn't in the response. Callingswitch_to_child()first works, becauseget_my_timetable()then goes throughget_timetable(student, date).Fix (WARNING: OUTDATED INFORMATION, read comment below)
get_my_timetable(), a parent account with no selected child and exactly one child indata["parentStudentids"]uses that child, through the existingget_timetable(student, date)path. Nothing is switched on the server.MissingDataExceptionasking them to callswitch_to_child()first.__get_date_planraisesMissingDataExceptioninstead ofIndexErrorwhen the response doesn't contain the expected marker.Tests
New
tests/test_timetable_parent.py: a parent with one child gets the child's timetable, a parent with zero, several orNonechildren getsMissingDataException, and an unexpected response raisesMissingDataException. The tests fail onmaster, and the suite passes. Also checked against a real one-child parent account: a school day returns 6 lessons.Fixes #81
Co-Authored-By: Claude Code