2013-09-29 21:02:01 +00:00
|
|
|
import datetime
|
|
|
|
|
2012-09-14 05:17:32 +00:00
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
2015-06-15 09:55:54 +00:00
|
|
|
from django.contrib.auth.models import User
|
2012-08-30 01:53:15 +00:00
|
|
|
from django.db import models
|
2015-06-26 03:46:09 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2012-08-30 01:53:15 +00:00
|
|
|
|
2018-12-29 00:36:13 +00:00
|
|
|
from symposion.managers import DefaultSelectRelatedManager
|
2017-05-07 03:22:28 +00:00
|
|
|
from symposion.text_parser import parse
|
2012-08-31 02:43:43 +00:00
|
|
|
from symposion.proposals.models import ProposalBase
|
|
|
|
from symposion.conference.models import Section
|
2014-12-18 14:17:35 +00:00
|
|
|
from symposion.speakers.models import Speaker
|
2012-08-31 02:43:43 +00:00
|
|
|
|
2012-08-30 01:53:15 +00:00
|
|
|
|
|
|
|
class Schedule(models.Model):
|
2018-12-29 00:36:13 +00:00
|
|
|
objects = DefaultSelectRelatedManager()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
section = models.OneToOneField(Section, verbose_name=_("Section"))
|
|
|
|
published = models.BooleanField(default=True, verbose_name=_("Published"))
|
|
|
|
hidden = models.BooleanField(_("Hide schedule from overall conference view"), default=False)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-07-18 07:09:17 +00:00
|
|
|
def __str__(self):
|
|
|
|
return "%s Schedule" % self.section
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2018-12-29 00:36:13 +00:00
|
|
|
class SymposionMeta:
|
|
|
|
select_related = ('section', )
|
|
|
|
|
2013-01-27 09:48:11 +00:00
|
|
|
class Meta:
|
|
|
|
ordering = ["section"]
|
2015-06-26 03:46:09 +00:00
|
|
|
verbose_name = _('Schedule')
|
|
|
|
verbose_name_plural = _('Schedules')
|
2012-08-30 01:53:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Day(models.Model):
|
2018-12-29 00:36:13 +00:00
|
|
|
objects = DefaultSelectRelatedManager()
|
|
|
|
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
schedule = models.ForeignKey(Schedule, verbose_name=_("Schedule"))
|
|
|
|
date = models.DateField(verbose_name=_("Date"))
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-07-18 07:09:17 +00:00
|
|
|
def __str__(self):
|
2018-12-29 00:36:13 +00:00
|
|
|
return "%s: %s" % (self.schedule.section.name, self.date)
|
|
|
|
|
|
|
|
class SymposionMeta:
|
|
|
|
select_related = ('schedule__section', )
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-08-30 05:58:03 +00:00
|
|
|
class Meta:
|
|
|
|
unique_together = [("schedule", "date")]
|
2013-01-27 09:48:11 +00:00
|
|
|
ordering = ["date"]
|
2015-06-26 03:46:09 +00:00
|
|
|
verbose_name = _("date")
|
|
|
|
verbose_name_plural = _("dates")
|
2012-08-30 01:53:15 +00:00
|
|
|
|
|
|
|
|
2012-08-30 05:58:03 +00:00
|
|
|
class Room(models.Model):
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
schedule = models.ForeignKey(Schedule, verbose_name=_("Schedule"))
|
|
|
|
name = models.CharField(max_length=65, verbose_name=_("Name"))
|
|
|
|
order = models.PositiveIntegerField(verbose_name=_("Order"))
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2017-10-15 05:07:56 +00:00
|
|
|
def __unicode__(self):
|
2016-12-24 06:55:11 +00:00
|
|
|
return self.name
|
2012-08-30 05:58:03 +00:00
|
|
|
|
2017-10-15 05:33:56 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
class Meta:
|
|
|
|
verbose_name = _("Room")
|
|
|
|
verbose_name_plural = _("Rooms")
|
|
|
|
|
2012-08-30 05:58:03 +00:00
|
|
|
|
2016-12-24 06:55:11 +00:00
|
|
|
class Track(models.Model):
|
|
|
|
name = models.CharField(max_length=80, verbose_name=_("Track"))
|
|
|
|
room = models.ForeignKey(Room)
|
|
|
|
day = models.ForeignKey(Day)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
unique_together = [('room', 'day')]
|
|
|
|
verbose_name = _("Track")
|
|
|
|
verbose_name_plural = _("Tracks")
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
schedule = models.ForeignKey(Schedule, verbose_name=_("schedule"))
|
|
|
|
label = models.CharField(max_length=50, verbose_name=_("Label"))
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-07-18 07:09:17 +00:00
|
|
|
def __str__(self):
|
2018-12-29 00:36:13 +00:00
|
|
|
return ": ".join((self.schedule.section.name, self.label))
|
2012-08-30 01:53:15 +00:00
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
class Meta:
|
|
|
|
verbose_name = _("Slot kind")
|
|
|
|
verbose_name_plural = _("Slot kinds")
|
|
|
|
|
2012-08-30 01:53:15 +00:00
|
|
|
|
|
|
|
class Slot(models.Model):
|
2018-12-29 00:36:13 +00:00
|
|
|
objects = DefaultSelectRelatedManager()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2016-12-10 06:37:01 +00:00
|
|
|
name = models.CharField(max_length=512, editable=False)
|
2015-06-26 03:46:09 +00:00
|
|
|
day = models.ForeignKey(Day, verbose_name=_("Day"))
|
|
|
|
kind = models.ForeignKey(SlotKind, verbose_name=_("Kind"))
|
|
|
|
start = models.TimeField(verbose_name=_("Start"))
|
|
|
|
end = models.TimeField(verbose_name=_("End"))
|
2016-12-09 21:30:44 +00:00
|
|
|
exclusive = models.BooleanField(
|
|
|
|
default=False,
|
|
|
|
help_text=_("Set to true if this is the only event during this "
|
|
|
|
"timeslot"),
|
|
|
|
)
|
2015-10-16 17:36:58 +00:00
|
|
|
content_override = models.TextField(blank=True, verbose_name=_("Content override"))
|
|
|
|
content_override_html = models.TextField(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()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-09-20 01:15:32 +00:00
|
|
|
def unassign(self):
|
|
|
|
"""
|
|
|
|
Unassign the associated content with this slot.
|
|
|
|
"""
|
2014-08-11 20:33:23 +00:00
|
|
|
content = self.content
|
|
|
|
if content and content.slot_id:
|
|
|
|
content.slot = None
|
|
|
|
content.save()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-09-14 05:17:32 +00:00
|
|
|
@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
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2013-09-29 21:02:01 +00:00
|
|
|
@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)
|
2014-09-22 02:11:12 +00:00
|
|
|
|
2013-09-29 21:02:01 +00:00
|
|
|
@property
|
|
|
|
def end_datetime(self):
|
|
|
|
return datetime.datetime(
|
|
|
|
self.day.date.year,
|
|
|
|
self.day.date.month,
|
|
|
|
self.day.date.day,
|
|
|
|
self.end.hour,
|
|
|
|
self.end.minute)
|
2014-09-22 02:11:12 +00:00
|
|
|
|
2013-09-29 21:02:01 +00:00
|
|
|
@property
|
|
|
|
def length_in_minutes(self):
|
|
|
|
return int(
|
|
|
|
(self.end_datetime - self.start_datetime).total_seconds() / 60)
|
2014-09-22 02:11:12 +00:00
|
|
|
|
2012-09-20 02:16:07 +00:00
|
|
|
@property
|
|
|
|
def rooms(self):
|
|
|
|
return Room.objects.filter(pk__in=self.slotroom_set.values("room"))
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-07-25 06:28:09 +00:00
|
|
|
def save(self, *args, **kwargs):
|
2018-12-29 00:36:13 +00:00
|
|
|
roomlist = ' '.join(map(str, self.rooms))
|
2015-07-25 06:28:09 +00:00
|
|
|
self.name = "%s %s (%s - %s) %s" % (self.day, self.kind, self.start, self.end, roomlist)
|
2016-02-20 23:06:09 +00:00
|
|
|
self.content_override_html = parse(self.content_override)
|
2015-07-25 06:28:09 +00:00
|
|
|
super(Slot, self).save(*args, **kwargs)
|
|
|
|
|
|
|
|
def __str__(self):
|
2018-12-29 00:36:13 +00:00
|
|
|
return "%s: %s" % (self.kind.schedule.section.name, self.name)
|
|
|
|
|
|
|
|
class SymposionMeta:
|
|
|
|
select_related = ('kind__schedule__section', 'day')
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-12-20 06:53:22 +00:00
|
|
|
class Meta:
|
|
|
|
ordering = ["day", "start", "end"]
|
2015-06-26 03:46:09 +00:00
|
|
|
verbose_name = _("slot")
|
|
|
|
verbose_name_plural = _("slots")
|
2012-08-30 17:52:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SlotRoom(models.Model):
|
|
|
|
"""
|
|
|
|
Links a slot with a room.
|
|
|
|
"""
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
slot = models.ForeignKey(Slot, verbose_name=_("Slot"))
|
|
|
|
room = models.ForeignKey(Room, verbose_name=_("Room"))
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-07-18 07:09:17 +00:00
|
|
|
def __str__(self):
|
|
|
|
return "%s %s" % (self.room, self.slot)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
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"]
|
2015-06-26 03:46:09 +00:00
|
|
|
verbose_name = _("Slot room")
|
|
|
|
verbose_name_plural = _("Slot rooms")
|
2012-08-31 02:36:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Presentation(models.Model):
|
2018-12-29 00:36:13 +00:00
|
|
|
objects = DefaultSelectRelatedManager()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
slot = models.OneToOneField(Slot, null=True, blank=True, related_name="content_ptr", verbose_name=_("Slot"))
|
|
|
|
title = models.CharField(max_length=100, verbose_name=_("Title"))
|
2015-10-16 17:36:58 +00:00
|
|
|
abstract = models.TextField(verbose_name=_("Abstract"))
|
|
|
|
abstract_html = models.TextField(blank=True)
|
2015-06-26 03:46:09 +00:00
|
|
|
speaker = models.ForeignKey(Speaker, related_name="presentations", verbose_name=_("Speaker"))
|
2014-12-18 14:17:35 +00:00
|
|
|
additional_speakers = models.ManyToManyField(Speaker, related_name="copresentations",
|
2015-06-26 03:46:09 +00:00
|
|
|
blank=True, verbose_name=_("Additional speakers"))
|
2016-09-18 00:45:42 +00:00
|
|
|
unpublish = models.BooleanField(
|
|
|
|
default=False,
|
|
|
|
verbose_name=_("Do not publish"),
|
|
|
|
)
|
2015-06-26 03:46:09 +00:00
|
|
|
cancelled = models.BooleanField(default=False, verbose_name=_("Cancelled"))
|
|
|
|
proposal_base = models.OneToOneField(ProposalBase, related_name="presentation", verbose_name=_("Proposal base"))
|
|
|
|
section = models.ForeignKey(Section, related_name="presentations", verbose_name=_("Section"))
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-10-16 17:36:58 +00:00
|
|
|
def save(self, *args, **kwargs):
|
|
|
|
self.abstract_html = parse(self.abstract)
|
|
|
|
return super(Presentation, self).save(*args, **kwargs)
|
|
|
|
|
2012-08-31 07:05:52 +00:00
|
|
|
@property
|
|
|
|
def number(self):
|
|
|
|
return self.proposal.number
|
2014-07-30 18:19:26 +00:00
|
|
|
|
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)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
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
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-07-18 07:09:17 +00:00
|
|
|
def __str__(self):
|
|
|
|
return "#%s %s (%s)" % (self.number, self.title, self.speaker)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-12-20 06:53:22 +00:00
|
|
|
class Meta:
|
|
|
|
ordering = ["slot"]
|
2015-06-26 03:46:09 +00:00
|
|
|
verbose_name = _("presentation")
|
|
|
|
verbose_name_plural = _("presentations")
|
2015-06-15 09:55:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Session(models.Model):
|
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
day = models.ForeignKey(Day, related_name="sessions", verbose_name=_("Day"))
|
|
|
|
slots = models.ManyToManyField(Slot, related_name="sessions", verbose_name=_("Slots"))
|
2015-06-15 09:55:54 +00:00
|
|
|
|
|
|
|
def sorted_slots(self):
|
|
|
|
return self.slots.order_by("start")
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
slots = self.sorted_slots()
|
|
|
|
if slots:
|
|
|
|
return list(slots)[0].start
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def end(self):
|
|
|
|
slots = self.sorted_slots()
|
|
|
|
if slots:
|
|
|
|
return list(slots)[-1].end
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
2016-12-10 06:00:49 +00:00
|
|
|
def chair(self):
|
|
|
|
for role in self.sessionrole_set.all():
|
|
|
|
if role.role == SessionRole.SESSION_ROLE_CHAIR:
|
|
|
|
return role
|
|
|
|
return None
|
|
|
|
|
2018-01-14 16:41:50 +00:00
|
|
|
@property
|
|
|
|
def rooms(self):
|
|
|
|
return Room.objects.filter(slotroom__slot__in=self.slots.all()).distinct()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def room_names(self):
|
|
|
|
return ', '.join(room.name for room in self.rooms)
|
|
|
|
|
2015-07-18 07:09:17 +00:00
|
|
|
def __str__(self):
|
2015-06-15 09:55:54 +00:00
|
|
|
start = self.start()
|
|
|
|
end = self.end()
|
2018-01-14 16:41:50 +00:00
|
|
|
rooms = ', '.join(room.name for room in self.rooms)
|
2015-06-15 09:55:54 +00:00
|
|
|
if start and end:
|
2018-01-14 16:41:50 +00:00
|
|
|
return "%s: %s - %s in %s" % (
|
2015-06-15 09:55:54 +00:00
|
|
|
self.day.date.strftime("%a"),
|
|
|
|
start.strftime("%X"),
|
2018-01-14 16:41:50 +00:00
|
|
|
end.strftime("%X"),
|
|
|
|
rooms
|
2015-06-15 09:55:54 +00:00
|
|
|
)
|
2015-07-18 07:09:17 +00:00
|
|
|
return ""
|
2015-06-15 09:55:54 +00:00
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
class Meta:
|
|
|
|
verbose_name = _("Session")
|
|
|
|
verbose_name_plural = _("Sessions")
|
|
|
|
|
2015-06-15 09:55:54 +00:00
|
|
|
|
|
|
|
class SessionRole(models.Model):
|
|
|
|
|
|
|
|
SESSION_ROLE_CHAIR = 1
|
|
|
|
SESSION_ROLE_RUNNER = 2
|
|
|
|
|
|
|
|
SESSION_ROLE_TYPES = [
|
2015-06-26 03:46:09 +00:00
|
|
|
(SESSION_ROLE_CHAIR, _("Session Chair")),
|
|
|
|
(SESSION_ROLE_RUNNER, _("Session Runner")),
|
2015-06-15 09:55:54 +00:00
|
|
|
]
|
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
session = models.ForeignKey(Session, verbose_name=_("Session"))
|
|
|
|
user = models.ForeignKey(User, verbose_name=_("User"))
|
|
|
|
role = models.IntegerField(choices=SESSION_ROLE_TYPES, verbose_name=_("Role"))
|
|
|
|
status = models.NullBooleanField(verbose_name=_("Status"))
|
2015-06-15 09:55:54 +00:00
|
|
|
|
|
|
|
submitted = models.DateTimeField(default=datetime.datetime.now)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
unique_together = [("session", "user", "role")]
|
2015-06-26 03:46:09 +00:00
|
|
|
verbose_name = _("Session role")
|
|
|
|
verbose_name_plural = _("Session roles")
|
2015-06-15 09:55:54 +00:00
|
|
|
|
2015-07-18 07:09:17 +00:00
|
|
|
def __str__(self):
|
|
|
|
return "%s %s: %s" % (self.user, self.session,
|
|
|
|
self.SESSION_ROLE_TYPES[self.role - 1][1])
|