Skip to content

Commit 2cc3c27

Browse files
committed
fix: handle calendar events with no ID
1 parent 625d220 commit 2cc3c27

File tree

6 files changed

+253
-251
lines changed

6 files changed

+253
-251
lines changed

apps/api/lectio/_forside.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ def forside(self):
108108
],
109109
}
110110
)
111-
print(forsideDict["undervisning"][navn][-1])
112111
for element in soup.find(
113112
"div", {"id": "s_m_Content_Content_skemaIsland_pa"}
114113
).find_all("div"):

apps/api/lectio/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def generatePayload(soup, eventTarget):
3030

3131
def skemaBrikExtract(skemabrik, modul_id=None):
3232
if modul_id is None:
33-
if matches := re.search(r"(absid|ProeveholdId)=([0-9]+)", skemabrik["href"]):
33+
if matches := re.search(r"(absid|ProeveholdId)=([0-9]+)", skemabrik.get("href") or ""):
3434
id_type, absid = matches.groups()
3535
if id_type == "ProeveholdId":
3636
absid = f"PH{absid}"

apps/frontend/src/lib/stores.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type { RawHomework } from "./types/homework";
1414
import type { Rooms } from "./types/rooms";
1515
import type {
1616
Information,
17-
information,
1817
RawInformation,
1918
} from "./types/information";
2019

apps/frontend/src/lib/types/lesson.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export type RawLesson = {
2-
absid: string;
2+
absid: null | string;
33
andet: null | string;
44
hold: null | string;
55
hold_id: null | string;
@@ -11,12 +11,12 @@ export type RawLesson = {
1111
};
1212

1313
export type Lesson = {
14-
id: string;
14+
id: string | null;
1515
date: string;
1616
class: string | null;
1717
name: string | null;
1818
note: string | null;
1919
room: string | null;
2020
status: string | null;
2121
teacher: string | null;
22-
}
22+
};

apps/frontend/src/routes/home/+page.svelte

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<div class="flex flex-col gap-4">
8181
<a
8282
class="unstyled"
83-
href={nextClass ? (nextClass.id.startsWith('PH') ? `/eksamen?id=${nextClass.id.substring(2)}&navn=${$frontPageStore?.name}` : `/modul?absid=${nextClass.id}`) : ''}
83+
href={nextClass ? (nextClass.id?.startsWith('PH') ? `/eksamen?id=${nextClass.id.substring(2)}&navn=${$frontPageStore?.name}` : `/modul?absid=${nextClass.id}`) : ''}
8484
>
8585
<Card class={cn("p-2 overflow-auto border-2", {"shrink-0": !nextClass})}>
8686
<div class="flex items-center justify-between">
@@ -163,9 +163,9 @@
163163
{#each classes as day}
164164
<h3 class="text-sm font-medium leading-7 unstyled">{day.name}</h3>
165165
{#each day.lessons as lesson}
166-
{@const url = lesson.id.startsWith("PH") ? `/eksamen?id=${lesson.id.substring(2)}&navn=${$frontPageStore?.name}` : `/modul?absid=${lesson.id}`}
166+
{@const url = lesson.id ? lesson.id.startsWith("PH") ? `/eksamen?id=${lesson.id.substring(2)}&navn=${$frontPageStore?.name}` : `/modul?absid=${lesson.id}` : null}
167167
<Card level="2" class="flex items-center p-3" error={lesson.status === 'aflyst'}
168-
on:click={() => !$isSmallScreen && goto(url)}>
168+
on:click={() => !$isSmallScreen && url && goto(url)}>
169169
<div
170170
class="flex items-stretch sm:items-center max-sm:flex-col-reverse max-sm:content-start flex-1 h-full min-w-0">
171171
<div class="max-sm:hidden flex justify-center shrink-0 w-11">
@@ -204,12 +204,14 @@
204204
{/if}
205205
</div>
206206
</div>
207-
<Button
208-
href={url}
209-
variant="ghost" size="sm" class="max-sm:hidden">
210-
Vis
211-
<ArrowRight class="ml-1 size-4" />
212-
</Button>
207+
{#if url}
208+
<Button
209+
href={url}
210+
variant="ghost" size="sm" class="max-sm:hidden">
211+
Vis
212+
<ArrowRight class="ml-1 size-4" />
213+
</Button>
214+
{/if}
213215
</Card>
214216
{/each}
215217
{/each}

0 commit comments

Comments
 (0)