2012-09-14 05:17:32 +00:00
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
2012-08-30 01:53:15 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2012-08-31 02:36:24 +00:00
|
|
|
from markitup.fields import MarkupField
|
2012-09-14 05:17:32 +00:00
|
|
|
from model_utils.managers import InheritanceManager
|
2012-08-31 02:36:24 +00:00
|
|
|
|
2012-08-31 02:43:43 +00:00
|
|
|
from symposion.proposals.models import ProposalBase
|
|
|
|
from symposion.conference.models import Section
|
|
|
|
|
2012-08-30 01:53:15 +00:00
|
|
|
|
|
|
|
class Schedule(models.Model):
|
|
|
|
|
|
|
|
section = models.OneToOneField(Section)
|
2012-11-25 18:26:25 +00:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return "%s Schedule" % self.section
|
2013-01-27 09:48:11 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ["section"]
|
2012-08-30 01:53:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Day(models.Model):
|
|
|
|
|
2012-08-30 05:58:03 +00:00
|
|
|
schedule = models.ForeignKey(Schedule)
|
2012-08-30 01:53:15 +00:00
|
|
|
date = models.DateField()
|
2012-08-30 05:58:03 +00:00
|
|
|
|
2012-11-25 18:26:25 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
return "%s" % self.date
|
|
|
|
|
2012-08-30 05:58:03 +00:00
|
|
|
class Meta:
|
|
|
|
unique_together = [("schedule", "date")]
|
2013-01-27 09:48:11 +00:00
|
|
|
ordering = ["date"]
|
2012-08-30 01:53:15 +00:00
|
|
|
|
|
|
|
|
2012-08-30 05:58:03 +00:00
|
|
|
class Room(models.Model):
|
2012-08-30 01:53:15 +00:00
|
|
|
|
2012-08-30 05:58:03 +00:00
|
|
|
schedule = models.ForeignKey(Schedule)
|
2012-08-30 01:53:15 +00:00
|
|
|
name = models.CharField(max_length=65)
|
2012-08-30 05:58:03 +00:00
|
|
|
order = models.PositiveIntegerField()
|
2012-09-20 02:17:48 +00:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
2012-08-30 05:58:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
2012-11-25 18:26:25 +00:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.label
|
2012-08-30 01:53:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Slot(models.Model):
|
|
|
|
|
|
|
|
day = models.ForeignKey(Day)
|
2012-08-30 05:58:03 +00:00
|
|
|
kind = models.ForeignKey(SlotKind)
|
2012-08-30 01:53:15 +00:00
|
|
|
start = models.TimeField()
|
|
|
|
end = models.TimeField()
|
2012-11-26 00:12:36 +00:00
|
|
|
content_override = MarkupField(blank=True)
|
2012-09-14 05:17:32 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
2012-09-20 01:15:32 +00:00
|
|
|
self.unassign()
|
|
|
|
content.slot = self
|
|
|
|
content.save()
|
|
|
|
|
|
|
|
def unassign(self):
|
|
|
|
"""
|
|
|
|
Unassign the associated content with this slot.
|
|
|
|
"""
|
2012-09-14 05:17:32 +00:00
|
|
|
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
|
2012-09-20 02:16:07 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def rooms(self):
|
|
|
|
return Room.objects.filter(pk__in=self.slotroom_set.values("room"))
|
2012-11-25 18:26:25 +00:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return "%s %s (%s - %s)" % (self.day, self.kind, self.start, self.end)
|
2012-12-20 06:53:22 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ["day", "start", "end"]
|
2012-08-30 17:52:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SlotRoom(models.Model):
|
|
|
|
"""
|
|
|
|
Links a slot with a room.
|
|
|
|
"""
|
|
|
|
|
|
|
|
slot = models.ForeignKey(Slot)
|
|
|
|
room = models.ForeignKey(Room)
|
2012-08-30 01:53:15 +00:00
|
|
|
|
2012-11-25 18:26:25 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
return "%s %s" % (self.room, self.slot)
|
|
|
|
|
2012-08-30 17:52:11 +00:00
|
|
|
class Meta:
|
|
|
|
unique_together = [("slot", "room")]
|
2012-12-20 06:53:22 +00:00
|
|
|
ordering = ["slot", "room__order"]
|
2012-08-31 02:36:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Presentation(models.Model):
|
|
|
|
|
2012-09-14 05:17:32 +00:00
|
|
|
slot = models.OneToOneField(Slot, null=True, blank=True, related_name="content_ptr")
|
2012-08-31 02:36:24 +00:00
|
|
|
title = models.CharField(max_length=100)
|
2012-08-31 02:57:58 +00:00
|
|
|
description = MarkupField()
|
|
|
|
abstract = MarkupField()
|
2012-08-31 02:36:24 +00:00
|
|
|
speaker = models.ForeignKey("speakers.Speaker", related_name="presentations")
|
2012-12-20 06:51:52 +00:00
|
|
|
additional_speakers = models.ManyToManyField("speakers.Speaker", related_name="copresentations", blank=True)
|
2012-08-31 02:36:24 +00:00
|
|
|
cancelled = models.BooleanField(default=False)
|
2012-09-13 20:39:58 +00:00
|
|
|
proposal_base = models.OneToOneField(ProposalBase, related_name="presentation")
|
2012-08-31 02:55:44 +00:00
|
|
|
section = models.ForeignKey(Section, related_name="presentations")
|
2012-08-31 02:43:43 +00:00
|
|
|
|
2012-08-31 07:05:52 +00:00
|
|
|
@property
|
|
|
|
def number(self):
|
|
|
|
return self.proposal.number
|
|
|
|
|
2012-08-31 02:43:43 +00:00
|
|
|
@property
|
|
|
|
def proposal(self):
|
2012-09-13 20:39:58 +00:00
|
|
|
if self.proposal_base_id is None:
|
|
|
|
return None
|
|
|
|
return ProposalBase.objects.get_subclass(pk=self.proposal_base_id)
|
2012-08-31 02:36:24 +00:00
|
|
|
|
|
|
|
def speakers(self):
|
|
|
|
yield self.speaker
|
|
|
|
for speaker in self.additional_speakers.all():
|
2012-12-20 06:55:14 +00:00
|
|
|
if speaker.user:
|
|
|
|
yield speaker
|
2012-08-31 02:36:24 +00:00
|
|
|
|
|
|
|
def __unicode__(self):
|
2012-08-31 07:05:52 +00:00
|
|
|
return "#%s %s (%s)" % (self.number, self.title, self.speaker)
|
2012-12-20 06:53:22 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ["slot"]
|