diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/absences/AbsenceCreationForm.vue b/aleksis/apps/alsijil/frontend/components/coursebook/absences/AbsenceCreationForm.vue index 601c2916a64e0f5b2ae83d13dc797519acfc9908..13fcd9ddcdb8872b96330f7a9748a45bcd42e55e 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/absences/AbsenceCreationForm.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/absences/AbsenceCreationForm.vue @@ -186,16 +186,19 @@ export default { getPeriodsForWeekday(weekday) { // Adapt from python conventions const pythonWeekday = weekday - 1; - return this.periodsByDay.find( + let periodsForWeekday = this.periodsByDay.find( (period) => period.weekday === pythonWeekday, - ).periods; + ); + if (!periodsForWeekday) return false; + return periodsForWeekday.periods; }, handleStartDate(date) { this.start = DateTime.fromISO(date); - if (this.periodsByDay.length > 0) { + if (this.periodsByDay && this.periodsByDay.length > 0) { // Select periods for day this.startPeriods = this.getPeriodsForWeekday(this.start.weekday); + if (!this.startPeriods) return; // Sync PeriodSelect const startTime = this.start.toFormat("HH:mm:ss"); this.startSlot = this.startPeriods.find( @@ -206,9 +209,10 @@ export default { handleEndDate(date) { this.end = DateTime.fromISO(date); - if (this.periodsByDay.length > 0) { + if (this.periodsByDay && this.periodsByDay.length > 0) { // Select periods for day this.endPeriods = this.getPeriodsForWeekday(this.end.weekday); + if (!this.endPeriods) return; // Sync PeriodSelect const endTime = this.end.toFormat("HH:mm:ss"); this.endSlot = this.endPeriods.find( diff --git a/aleksis/apps/alsijil/schema/__init__.py b/aleksis/apps/alsijil/schema/__init__.py index 0c75517fd62d63d0c181156c9d2529a711ff7590..1614cf0f3000c95915a1fdef92d114b443525e03 100644 --- a/aleksis/apps/alsijil/schema/__init__.py +++ b/aleksis/apps/alsijil/schema/__init__.py @@ -368,7 +368,9 @@ class Query(graphene.ObjectType): Slot = apps.get_model("lesrooster", "Slot") ValidityRange = apps.get_model("lesrooster", "ValidityRange") slots = ( - Slot.objects.filter(time_grid__validity_range=ValidityRange.current) + Slot.objects.filter( + time_grid__validity_range=ValidityRange.current, period__isnull=False + ) .order_by("weekday") .values("weekday", "period", "time_start", "time_end") )