Skip to content
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
20 changes: 15 additions & 5 deletions custom_components/aula/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
# schools that do not expose 0030 to guardians.
MU_OPGAVER_WIDGETS = ("0030", "0023")

# Widgets that can mint a token for the Min Uddannelse "ugebrev" endpoint,
# in order of preference. 0029 is the dedicated "Ugenoter" widget; 0023
# ("MinUddannelse - SSO") is accepted by the same endpoint and is available at
# schools that do not expose 0029 to guardians.
MU_UGEPLAN_WIDGETS = ("0029", "0023")


def decode_mu_deeplink(url):
"""Return the MinUddannelse page URL embedded in an opgave "url" field.
Expand Down Expand Up @@ -1020,23 +1026,27 @@ def mu_opgaver(week, thisnext):

if len(self.widgets) == 0:
self.get_widgets()
mu_uge_widget = next(
(widget for widget in MU_UGEPLAN_WIDGETS if widget in self.widgets),
None,
)
if (
"0029" not in self.widgets
mu_uge_widget is None
and "0004" not in self.widgets
and "0062" not in self.widgets
and "0001" not in self.widgets
):
_LOGGER.error(
"You have enabled ugeplaner, but we cannot find any supported widgets (0029,0004,0001) in Aula."
"You have enabled ugeplaner, but we cannot find any supported widgets (0029,0023,0004,0001) in Aula."
)
if "0029" in self.widgets and "0004" in self.widgets:
if mu_uge_widget is not None and "0004" in self.widgets:
_LOGGER.warning(
"Multiple sources for ugeplaner is untested and might cause problems."
)

def ugeplan(week, thisnext):
if "0029" in self.widgets:
token = self.get_token("0029")
if mu_uge_widget is not None:
token = self.get_token(mu_uge_widget)
get_payload = (
"/ugebrev?assuranceLevel=2&childFilter="
+ childUserIds
Expand Down
Loading