<s> from __future__ import unicode_literals <EOL> import datetime <EOL> from django . core . exceptions import ObjectDoesNotExist <EOL> from django . contrib . auth . models import User <EOL> from django . db import models <EOL> from django . utils . encoding import python_2_unicode_compatible <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from symposion . markdown_parser import parse <EOL> from symposion . proposals . models import ProposalBase <EOL> from symposion . conference . models import Section <EOL> from symposion . speakers . models import Speaker <EOL> @ python_2_unicode_compatible <EOL> class Schedule ( models . Model ) : <EOL> section = models . OneToOneField ( Section , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> published = models . BooleanField ( default = True , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> hidden = models . BooleanField ( _ ( "<STR_LIT>" ) , default = False ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % self . section <EOL> class Meta : <EOL> ordering = [ "<STR_LIT>" ] <EOL> verbose_name = _ ( '<STR_LIT>' ) <EOL> verbose_name_plural = _ ( '<STR_LIT>' ) <EOL> @ python_2_unicode_compatible <EOL> class Day ( models . Model ) : <EOL> schedule = models . ForeignKey ( Schedule , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> date = models . DateField ( verbose_name = _ ( "<STR_LIT>" ) ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT:%s>" % self . date <EOL> class Meta : <EOL> unique_together = [ ( "<STR_LIT>" , "<STR_LIT:date>" ) ] <EOL> ordering = [ "<STR_LIT:date>" ] <EOL> verbose_name = _ ( "<STR_LIT:date>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> @ python_2_unicode_compatible <EOL> class Room ( models . Model ) : <EOL> schedule = models . ForeignKey ( Schedule , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> name = models . CharField ( max_length = <NUM_LIT> , verbose_name = _ ( "<STR_LIT:Name>" ) ) <EOL> order = models . PositiveIntegerField ( verbose_name = _ ( "<STR_LIT>" ) ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> class Meta : <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> @ python_2_unicode_compatible <EOL> class SlotKind ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> schedule = models . ForeignKey ( Schedule , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> label = models . CharField ( max_length = <NUM_LIT:50> , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> def __str__ ( self ) : <EOL> return self . label <EOL> class Meta : <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> @ python_2_unicode_compatible <EOL> class Slot ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:100> , editable = False ) <EOL> day = models . ForeignKey ( Day , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> kind = models . ForeignKey ( SlotKind , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> start = models . TimeField ( verbose_name = _ ( "<STR_LIT>" ) ) <EOL> end = models . TimeField ( verbose_name = _ ( "<STR_LIT>" ) ) <EOL> content_override = models . TextField ( blank = True , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> content_override_html = models . TextField ( blank = True ) <EOL> def assign ( self , content ) : <EOL> """<STR_LIT>""" <EOL> self . unassign ( ) <EOL> content . slot = self <EOL> content . save ( ) <EOL> def unassign ( self ) : <EOL> """<STR_LIT>""" <EOL> content = self . content <EOL> if content and content . slot_id : <EOL> content . slot = None <EOL> content . save ( ) <EOL> @ property <EOL> def content ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return self . content_ptr <EOL> except ObjectDoesNotExist : <EOL> return None <EOL> @ property <EOL> def start_datetime ( self ) : <EOL> return datetime . datetime ( <EOL> self . day . date . year , <EOL> self . day . date . month , <EOL> self . day . date . day , <EOL> self . start . hour , <EOL> self . start . minute ) <EOL> @ property <EOL> def end_datetime ( self ) : <EOL> return datetime . datetime ( <EOL> self . day . date . year , <EOL> self . day . date . month , <EOL> self . day . date . day , <EOL> self . end . hour , <EOL> self . end . minute ) <EOL> @ property <EOL> def length_in_minutes ( self ) : <EOL> return int ( <EOL> ( self . end_datetime - self . start_datetime ) . total_seconds ( ) / <NUM_LIT> ) <EOL> @ property <EOL> def rooms ( self ) : <EOL> return Room . objects . filter ( pk__in = self . slotroom_set . values ( "<STR_LIT>" ) ) <EOL> def save ( self , * args , ** kwargs ) : <EOL> roomlist = '<STR_LIT:U+0020>' . join ( map ( lambda r : r . __unicode__ ( ) , self . rooms ) ) <EOL> self . name = "<STR_LIT>" % ( self . day , self . kind , self . start , self . end , roomlist ) <EOL> self . content_override_html = parse ( self . content_override ) <EOL> super ( Slot , self ) . save ( * args , ** kwargs ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> class Meta : <EOL> ordering = [ "<STR_LIT>" , "<STR_LIT:start>" , "<STR_LIT:end>" ] <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> @ python_2_unicode_compatible <EOL> class SlotRoom ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> slot = models . ForeignKey ( Slot , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> room = models . ForeignKey ( Room , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . room , self . slot ) <EOL> class Meta : <EOL> unique_together = [ ( "<STR_LIT>" , "<STR_LIT>" ) ] <EOL> ordering = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> @ python_2_unicode_compatible <EOL> class Presentation ( models . Model ) : <EOL> slot = models . OneToOneField ( Slot , null = True , blank = True , related_name = "<STR_LIT>" , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> title = models . CharField ( max_length = <NUM_LIT:100> , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> description = models . TextField ( verbose_name = _ ( "<STR_LIT>" ) ) <EOL> description_html = models . TextField ( blank = True ) <EOL> abstract = models . TextField ( verbose_name = _ ( "<STR_LIT>" ) ) <EOL> abstract_html = models . TextField ( blank = True ) <EOL> speaker = models . ForeignKey ( Speaker , related_name = "<STR_LIT>" , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> additional_speakers = models . ManyToManyField ( Speaker , related_name = "<STR_LIT>" , <EOL> blank = True , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> cancelled = models . BooleanField ( default = False , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> proposal_base = models . OneToOneField ( ProposalBase , related_name = "<STR_LIT>" , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> section = models . ForeignKey ( Section , related_name = "<STR_LIT>" , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> def save ( self , * args , ** kwargs ) : <EOL> self . description_html = parse ( self . description ) <EOL> self . abstract_html = parse ( self . abstract ) <EOL> return super ( Presentation , self ) . save ( * args , ** kwargs ) <EOL> @ property <EOL> def number ( self ) : <EOL> return self . proposal . number <EOL> @ property <EOL> def proposal ( self ) : <EOL> if self . proposal_base_id is None : <EOL> return None <EOL> return ProposalBase . objects . get_subclass ( pk = self . proposal_base_id ) <EOL> def speakers ( self ) : <EOL> yield self . speaker <EOL> for speaker in self . additional_speakers . all ( ) : <EOL> if speaker . user : <EOL> yield speaker <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . number , self . title , self . speaker ) <EOL> class Meta : <EOL> ordering = [ "<STR_LIT>" ] <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> @ python_2_unicode_compatible <EOL> class Session ( models . Model ) : <EOL> day = models . ForeignKey ( Day , related_name = "<STR_LIT>" , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> slots = models . ManyToManyField ( Slot , related_name = "<STR_LIT>" , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> def sorted_slots ( self ) : <EOL> return self . slots . order_by ( "<STR_LIT:start>" ) <EOL> def start ( self ) : <EOL> slots = self . sorted_slots ( ) <EOL> if slots : <EOL> return list ( slots ) [ <NUM_LIT:0> ] . start <EOL> else : <EOL> return None <EOL> def end ( self ) : <EOL> slots = self . sorted_slots ( ) <EOL> if slots : <EOL> return list ( slots ) [ - <NUM_LIT:1> ] . end <EOL> else : <EOL> return None <EOL> def __str__ ( self ) : <EOL> start = self . start ( ) <EOL> end = self . end ( ) <EOL> if start and end : <EOL> return "<STR_LIT>" % ( <EOL> self . day . date . strftime ( "<STR_LIT>" ) , <EOL> start . strftime ( "<STR_LIT>" ) , <EOL> end . strftime ( "<STR_LIT>" ) <EOL> ) <EOL> return "<STR_LIT>" <EOL> class Meta : <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> @ python_2_unicode_compatible <EOL> class SessionRole ( models . Model ) : <EOL> SESSION_ROLE_CHAIR = <NUM_LIT:1> <EOL> SESSION_ROLE_RUNNER = <NUM_LIT:2> <EOL> SESSION_ROLE_TYPES = [ <EOL> ( SESSION_ROLE_CHAIR , _ ( "<STR_LIT>" ) ) , <EOL> ( SESSION_ROLE_RUNNER , _ ( "<STR_LIT>" ) ) , <EOL> ] <EOL> session = models . ForeignKey ( Session , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> user = models . ForeignKey ( User , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> role = models . IntegerField ( choices = SESSION_ROLE_TYPES , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> status = models . NullBooleanField ( verbose_name = _ ( "<STR_LIT>" ) ) <EOL> submitted = models . DateTimeField ( default = datetime . datetime . now ) <EOL> class Meta : <EOL> unique_together = [ ( "<STR_LIT>" , "<STR_LIT:user>" , "<STR_LIT>" ) ] <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . user , self . session , <EOL> self . SESSION_ROLE_TYPES [ self . role - <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) </s>
