File diff f4c4009c4db3 → cb4b0fac3871
symposion/schedule/models.py
Show inline comments
...
 
@@ -59,50 +59,51 @@ class SlotKind(models.Model):
 

	
 

	
 
class Slot(models.Model):
 

	
 
    day = models.ForeignKey(Day)
 
    kind = models.ForeignKey(SlotKind)
 
    start = models.TimeField()
 
    end = models.TimeField()
 
    content_override = MarkupField(blank=True)
 

	
 
    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()
 
            presentation = self.content
 
            presentation.slot = None
 
            presentation.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
 

	
 
    @property
 
    def start_datetime(self):
 
        return datetime.datetime(
 
            self.day.date.year,
 
            self.day.date.month,
 
            self.day.date.day,
 
            self.start.hour,
 
            self.start.minute)
 

	
 
    @property
 
    def end_datetime(self):
 
        return datetime.datetime(