Skip to content
Snippets Groups Projects
Commit dabd1769 authored by Felix Blanke's avatar Felix Blanke
Browse files

Fix import code

parent 034748fe
Branches
No related tags found
3 merge requests!17Add view to clear schedule,!4Draft: Add object import from JSON data,!3Merge into fork's `main` branch
...@@ -212,17 +212,19 @@ class Event(models.Model): ...@@ -212,17 +212,19 @@ class Event(models.Model):
slots_in_an_hour = schedule["input"]["timeslots"]["info"]["duration"] slots_in_an_hour = schedule["input"]["timeslots"]["info"]["duration"]
for scheduled_slot in schedule["scheduled_aks"]: for scheduled_slot in schedule["scheduled_aks"]:
slot = AKSlot.objects.get(scheduled_slot["ak_id"]) slot = AKSlot.objects.get(id=int(scheduled_slot["ak_id"]))
slot.room = scheduled_slot["room_id"] slot.room = Room.objects.get(id=int(scheduled_slot["room_id"]))
start = min(scheduled_slot["time_slot_ids"]) scheduled_slot["timeslot_ids"] = list(map(int, scheduled_slot["timeslot_ids"]))
end = max(scheduled_slot["time_slot_ids"])
start = min(scheduled_slot["timeslot_ids"])
end = max(scheduled_slot["timeslot_ids"])
slot.start = self.time_slot(time_slot_index=start, slot.start = self.time_slot(time_slot_index=start,
slots_in_an_hour=slots_in_an_hour) slots_in_an_hour=slots_in_an_hour).start
slot.end = self.time_slot(time_slot_index=end + 1,
slots_in_an_hour=slots_in_an_hour)
slot.duration = (end - start + 1) * timedelta(hours=(1.0 / slots_in_an_hour)).total_seconds() / 3600.0
slot.save()
class AKOwner(models.Model): class AKOwner(models.Model):
""" An AKOwner describes the person organizing/holding an AK. """ An AKOwner describes the person organizing/holding an AK.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment