From dafdcf591994c91df1d0ea001a560a48862e3280 Mon Sep 17 00:00:00 2001
From: Felix Blanke <info@fblanke.de>
Date: Sat, 8 Feb 2025 12:59:44 +0100
Subject: [PATCH] If no owner availability is given, assume avail for full
 event

---
 AKModel/models.py                 | 3 ++-
 AKModel/tests/test_json_export.py | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/AKModel/models.py b/AKModel/models.py
index 8601a992..f11c66e2 100644
--- a/AKModel/models.py
+++ b/AKModel/models.py
@@ -1006,7 +1006,8 @@ class AKSlot(models.Model):
             ak_time_constraints = []
 
         def _owner_time_constraints(owner: AKOwner):
-            if Availability.is_event_covered(self.event, owner.availabilities.all()):
+            owner_avails = owner.availabilities.all()
+            if not owner_avails or Availability.is_event_covered(self.event, owner_avails):
                 return []
             return [f"availability-person-{owner.pk}"]
 
diff --git a/AKModel/tests/test_json_export.py b/AKModel/tests/test_json_export.py
index d53cd4c5..5a604dc7 100644
--- a/AKModel/tests/test_json_export.py
+++ b/AKModel/tests/test_json_export.py
@@ -479,6 +479,10 @@ class JSONExportTest(TestCase):
 
                     for owner in slot.ak.owners.all():
                         # restricted owner availability
+                        if not owner.availabilities.all():
+                            # no availability for owner -> assume full event is covered
+                            continue
+
                         if not Availability.is_event_covered(
                             slot.event, owner.availabilities.all()
                         ):
-- 
GitLab