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

Fix migration erros

parent 1db999b1
No related branches found
No related tags found
6 merge requests!262[WIP] compatibility with koma solver import/export,!261[WIP] compatibility with koma solver import/export,!260[WIP] import/export merge,!259Add view to clear schedule,!237Draft: add tests on json export,!235Merge fork for interoperability of KoMa solver
...@@ -297,22 +297,6 @@ class AKOwner(models.Model): ...@@ -297,22 +297,6 @@ class AKOwner(models.Model):
""" """
return AKOwner.objects.get(event=event, slug=slug) return AKOwner.objects.get(event=event, slug=slug)
def as_json(self) -> str:
data = {
"id": self.pk,
"info": {
"name": self.name,
},
"capacity": self.capacity,
"fulfilled_room_constraints": [constraint.name
for constraint in self.properties.all()],
"time_constraints": [f"availability-room-{self.pk}"]
}
return json.dumps(data)
class AKCategory(models.Model): class AKCategory(models.Model):
""" An AKCategory describes the characteristics of an AK, e.g. content vs. recreational. """ An AKCategory describes the characteristics of an AK, e.g. content vs. recreational.
...@@ -590,6 +574,20 @@ class Room(models.Model): ...@@ -590,6 +574,20 @@ class Room(models.Model):
def __str__(self): def __str__(self):
return self.title return self.title
def as_json(self) -> str:
data = {
"id": self.pk,
"info": {
"name": self.name,
},
"capacity": self.capacity,
"fulfilled_room_constraints": [constraint.name
for constraint in self.properties.all()],
"time_constraints": [f"availability-room-{self.pk}"]
}
return json.dumps(data)
class AKSlot(models.Model): class AKSlot(models.Model):
""" An AK Mapping matches an AK to a room during a certain time. """ An AK Mapping matches an AK to a room during a certain time.
...@@ -685,6 +683,28 @@ class AKSlot(models.Model): ...@@ -685,6 +683,28 @@ class AKSlot(models.Model):
self.duration = min(self.duration, event_duration_hours) self.duration = min(self.duration, event_duration_hours)
super().save(force_insert, force_update, using, update_fields) super().save(force_insert, force_update, using, update_fields)
def as_json(self) -> str:
data = {
"id": self.pk,
"duration": int(self.duration * self.slots_in_an_hour),
"properties": {},
"room_constraints": [constraint.name
for constraint in self.ak.requirements.all()],
"time_constraints": ["resolution"] if self.ak.reso else [],
"info": {
"name": self.ak.name,
"head": ", ".join([str(owner)
for owner in self.ak.owners.all()]),
"description": self.ak.description,
"reso": self.ak.reso,
},
}
data["time_constraints"].append(f"availability-ak-{self.pk}")
data["time_constraints"] += [f"availability-person-{owner.pk}"
for owner in self.ak.owners.all()]
return json.dumps(data)
class AKOrgaMessage(models.Model): class AKOrgaMessage(models.Model):
""" """
......
...@@ -8,7 +8,7 @@ from django.views.generic import ListView, DetailView ...@@ -8,7 +8,7 @@ from django.views.generic import ListView, DetailView
from AKModel.metaviews.admin import AdminViewMixin, FilterByEventSlugMixin, EventSlugMixin, IntermediateAdminView, \ from AKModel.metaviews.admin import AdminViewMixin, FilterByEventSlugMixin, EventSlugMixin, IntermediateAdminView, \
IntermediateAdminActionView IntermediateAdminActionView
from AKModel.models import AKRequirement, AKSlot, Event, AKOrgaMessage, AK from AKModel.models import AKRequirement, AKSlot, Event, AKOrgaMessage, AK, Room, AKOwner
class AKRequirementOverview(AdminViewMixin, FilterByEventSlugMixin, ListView): class AKRequirementOverview(AdminViewMixin, FilterByEventSlugMixin, ListView):
...@@ -81,8 +81,6 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView): ...@@ -81,8 +81,6 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
for person in AKOwner.objects.filter(event=self.event) for person in AKOwner.objects.filter(event=self.event)
for availability in person.availabilities.all()} for availability in person.availabilities.all()}
for block in self.event.time_slots(slots_in_an_hour=SLOTS_IN_AN_HOUR): for block in self.event.time_slots(slots_in_an_hour=SLOTS_IN_AN_HOUR):
current_block = [] current_block = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment