From fe81ec8a99ca9543811afaccf9f6067935a18540 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Mon, 15 Jul 2024 21:38:10 +0200
Subject: [PATCH] Fix and improve absences query for coursebook

---
 .../alsijil/frontend/components/coursebook/Coursebook.vue     | 2 +-
 aleksis/apps/alsijil/models.py                                | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue b/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue
index 683d87c1f..2cfd4a686 100644
--- a/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue
+++ b/aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue
@@ -192,7 +192,7 @@ export default {
         dateStart: this.dateStart,
         dateEnd: this.dateEnd,
         incomplete: !!this.incomplete,
-        absencesExist: !!this.absencesExist,
+        absencesExist: !!this.absencesExist && this.pageType === "absences",
       };
     },
     filters: {
diff --git a/aleksis/apps/alsijil/models.py b/aleksis/apps/alsijil/models.py
index b80ac3e52..6b1281023 100644
--- a/aleksis/apps/alsijil/models.py
+++ b/aleksis/apps/alsijil/models.py
@@ -567,8 +567,8 @@ class Documentation(CalendarEvent):
                 if (incomplete and doc.topic) or (
                     absences_exist
                     and (
-                        not doc.participations.exists
-                        or not doc.participations.filter(absence_reason__isnull=False).exists()
+                        not doc.participations.all()
+                        or not [d for d in doc.participations.all() if d.absence_reason]
                     )
                 ):
                     continue
-- 
GitLab