Skip to content

Commit

Permalink
fix: handle calendar events with no ID
Browse files Browse the repository at this point in the history
  • Loading branch information
johanohly committed Sep 26, 2024
1 parent 625d220 commit 2cc3c27
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 251 deletions.
1 change: 0 additions & 1 deletion apps/api/lectio/_forside.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def forside(self):
],
}
)
print(forsideDict["undervisning"][navn][-1])
for element in soup.find(
"div", {"id": "s_m_Content_Content_skemaIsland_pa"}
).find_all("div"):
Expand Down
2 changes: 1 addition & 1 deletion apps/api/lectio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def generatePayload(soup, eventTarget):

def skemaBrikExtract(skemabrik, modul_id=None):
if modul_id is None:
if matches := re.search(r"(absid|ProeveholdId)=([0-9]+)", skemabrik["href"]):
if matches := re.search(r"(absid|ProeveholdId)=([0-9]+)", skemabrik.get("href") or ""):
id_type, absid = matches.groups()
if id_type == "ProeveholdId":
absid = f"PH{absid}"
Expand Down
1 change: 0 additions & 1 deletion apps/frontend/src/lib/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type { RawHomework } from "./types/homework";
import type { Rooms } from "./types/rooms";
import type {
Information,
information,
RawInformation,
} from "./types/information";

Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/src/lib/types/lesson.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type RawLesson = {
absid: string;
absid: null | string;
andet: null | string;
hold: null | string;
hold_id: null | string;
Expand All @@ -11,12 +11,12 @@ export type RawLesson = {
};

export type Lesson = {
id: string;
id: string | null;
date: string;
class: string | null;
name: string | null;
note: string | null;
room: string | null;
status: string | null;
teacher: string | null;
}
};
20 changes: 11 additions & 9 deletions apps/frontend/src/routes/home/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<div class="flex flex-col gap-4">
<a
class="unstyled"
href={nextClass ? (nextClass.id.startsWith('PH') ? `/eksamen?id=${nextClass.id.substring(2)}&navn=${$frontPageStore?.name}` : `/modul?absid=${nextClass.id}`) : ''}
href={nextClass ? (nextClass.id?.startsWith('PH') ? `/eksamen?id=${nextClass.id.substring(2)}&navn=${$frontPageStore?.name}` : `/modul?absid=${nextClass.id}`) : ''}
>
<Card class={cn("p-2 overflow-auto border-2", {"shrink-0": !nextClass})}>
<div class="flex items-center justify-between">
Expand Down Expand Up @@ -163,9 +163,9 @@
{#each classes as day}
<h3 class="text-sm font-medium leading-7 unstyled">{day.name}</h3>
{#each day.lessons as lesson}
{@const url = lesson.id.startsWith("PH") ? `/eksamen?id=${lesson.id.substring(2)}&navn=${$frontPageStore?.name}` : `/modul?absid=${lesson.id}`}
{@const url = lesson.id ? lesson.id.startsWith("PH") ? `/eksamen?id=${lesson.id.substring(2)}&navn=${$frontPageStore?.name}` : `/modul?absid=${lesson.id}` : null}
<Card level="2" class="flex items-center p-3" error={lesson.status === 'aflyst'}
on:click={() => !$isSmallScreen && goto(url)}>
on:click={() => !$isSmallScreen && url && goto(url)}>
<div
class="flex items-stretch sm:items-center max-sm:flex-col-reverse max-sm:content-start flex-1 h-full min-w-0">
<div class="max-sm:hidden flex justify-center shrink-0 w-11">
Expand Down Expand Up @@ -204,12 +204,14 @@
{/if}
</div>
</div>
<Button
href={url}
variant="ghost" size="sm" class="max-sm:hidden">
Vis
<ArrowRight class="ml-1 size-4" />
</Button>
{#if url}
<Button
href={url}
variant="ghost" size="sm" class="max-sm:hidden">
Vis
<ArrowRight class="ml-1 size-4" />
</Button>
{/if}
</Card>
{/each}
{/each}
Expand Down
Loading

0 comments on commit 2cc3c27

Please sign in to comment.