From dabd1769bc9ea3c54c1a4194da85896a1fcb743d Mon Sep 17 00:00:00 2001 From: Felix Blanke <info@fblanke.de> Date: Tue, 28 May 2024 21:30:27 +0200 Subject: [PATCH] Fix import code --- AKModel/models.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/AKModel/models.py b/AKModel/models.py index 4cc9343d..5337bb4f 100644 --- a/AKModel/models.py +++ b/AKModel/models.py @@ -212,17 +212,19 @@ class Event(models.Model): slots_in_an_hour = schedule["input"]["timeslots"]["info"]["duration"] for scheduled_slot in schedule["scheduled_aks"]: - slot = AKSlot.objects.get(scheduled_slot["ak_id"]) - slot.room = scheduled_slot["room_id"] + slot = AKSlot.objects.get(id=int(scheduled_slot["ak_id"])) + slot.room = Room.objects.get(id=int(scheduled_slot["room_id"])) - start = min(scheduled_slot["time_slot_ids"]) - end = max(scheduled_slot["time_slot_ids"]) + scheduled_slot["timeslot_ids"] = list(map(int, scheduled_slot["timeslot_ids"])) + + start = min(scheduled_slot["timeslot_ids"]) + end = max(scheduled_slot["timeslot_ids"]) slot.start = self.time_slot(time_slot_index=start, - slots_in_an_hour=slots_in_an_hour) - slot.end = self.time_slot(time_slot_index=end + 1, - slots_in_an_hour=slots_in_an_hour) + slots_in_an_hour=slots_in_an_hour).start + slot.duration = (end - start + 1) * timedelta(hours=(1.0 / slots_in_an_hour)).total_seconds() / 3600.0 + slot.save() class AKOwner(models.Model): """ An AKOwner describes the person organizing/holding an AK. -- GitLab