@@ -31,53 +31,59 @@ class Room(models.Model):
class SlotKind(models.Model):
"""
A slot kind represents what kind a slot is. For example, a slot can be a
break, lunch, or X-minute talk.
schedule = models.ForeignKey(Schedule)
label = models.CharField(max_length=50)
class Slot(models.Model):
day = models.ForeignKey(Day)
kind = models.ForeignKey(SlotKind)
start = models.TimeField()
end = models.TimeField()
def assign(self, content):
Assign the given content to this slot and if a previous slot content
was given we need to unlink it to avoid integrity errors.
self.unassign()
content.slot = self
content.save()
def unassign(self):
Unassign the associated content with this slot.
if self.content and self.content.slot_id:
self.content.slot = None
self.content.save()
@property
def content(self):
Return the content this slot represents.
@@@ hard-coded for presentation for now
try:
return self.content_ptr
except ObjectDoesNotExist:
return None
class SlotRoom(models.Model):
Links a slot with a room.
slot = models.ForeignKey(Slot)
room = models.ForeignKey(Room)
class Meta:
unique_together = [("slot", "room")]