# Path: symposion/schedule/models.py
# class Day(models.Model):
#     
#     schedule = models.ForeignKey(Schedule)
#     date = models.DateField()
#     
#     def __unicode__(self):
#         return "%s" % self.date
#     
#     class Meta:
#         unique_together = [("schedule", "date")]
# 
# 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()
#     
#     @property
#     def duration(self):
#         start_dt = datetime.strptime(self.start.isoformat(), "%H:%M:%S")
#         end_dt = datetime.strptime(self.end.isoformat(), "%H:%M:%S")
#         delta = end_dt - start_dt
#         return delta.seconds // 60
#     
#     @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 rooms(self):
#         return Room.objects.filter(pk__in=self.slotroom_set.values("room"))
#     
#     @property
#     def start_date(self):
#         return datetime.combine(self.day.date, self.start)
#     
#     @property
#     def end_date(self):
#         return datetime.combine(self.day.date, self.end)
#     
#     def __unicode__(self):
#         return "%s %s (%s - %s)" % (self.day, self.kind, self.start, self.end)
#     
#     class Meta:
#         ordering = ["day", "start", "end"]


from datetime import datetime
from django.db import models
from django.contrib.auth.models import User
from symposion.schedule.models import Day, Slot





class Session(models.Model):
    
    day = models.ForeignKey(Day, related_name="sessions")
    slots = models.ManyToManyField(Slot, related_name="sessions")
    
    def sorted_slots(self):
        return self.slots.order_by("start")
    
    def start(self):
        slots = self.sorted_slots()

# Path: symposion/schedule/models.py
# class Day(models.Model):
#     
#     schedule = models.ForeignKey(Schedule)
#     date = models.DateField()
#     
#     def __unicode__(self):
#         return "%s" % self.date
#     
#     class Meta:
#         unique_together = [("schedule", "date")]
# 
# 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()
#     
#     @property
#     def duration(self):
#         start_dt = datetime.strptime(self.start.isoformat(), "%H:%M:%S")
#         end_dt = datetime.strptime(self.end.isoformat(), "%H:%M:%S")
#         delta = end_dt - start_dt
#         return delta.seconds // 60
#     
#     @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 rooms(self):
#         return Room.objects.filter(pk__in=self.slotroom_set.values("room"))
#     
#     @property
#     def start_date(self):
#         return datetime.combine(self.day.date, self.start)
#     
#     @property
#     def end_date(self):
#         return datetime.combine(self.day.date, self.end)
#     
#     def __unicode__(self):
#         return "%s %s (%s - %s)" % (self.day, self.kind, self.start, self.end)
#     
#     class Meta:
#         ordering = ["day", "start", "end"]


# Path: pycon/schedule/models.py
from datetime import datetime
from django.db import models
from django.contrib.auth.models import User
from symposion.schedule.models import Day, Slot






class Session(models.Model):
    
    day = models.ForeignKey(Day, related_name="sessions")
    slots = models.ManyToManyField(Slot, related_name="sessions")
    
    def sorted_slots(self):
        return self.slots.order_by("start")
    
    def start(self):
        slots = self.sorted_slots()

        if slots: