<s> from __future__ import unicode_literals <EOL> from django . db import models <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from django . utils . encoding import python_2_unicode_compatible <EOL> from timezone_field import TimeZoneField <EOL> CONFERENCE_CACHE = { } <EOL> @ python_2_unicode_compatible <EOL> class Conference ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> title = models . CharField ( _ ( "<STR_LIT>" ) , max_length = <NUM_LIT:100> ) <EOL> start_date = models . DateField ( _ ( "<STR_LIT>" ) , null = True , blank = True ) <EOL> end_date = models . DateField ( _ ( "<STR_LIT>" ) , null = True , blank = True ) <EOL> timezone = TimeZoneField ( blank = True , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> def __str__ ( self ) : <EOL> return self . title <EOL> def save ( self , * args , ** kwargs ) : <EOL> super ( Conference , self ) . save ( * args , ** kwargs ) <EOL> if self . id in CONFERENCE_CACHE : <EOL> del CONFERENCE_CACHE [ self . id ] <EOL> def delete ( self ) : <EOL> pk = self . pk <EOL> super ( Conference , self ) . delete ( ) <EOL> try : <EOL> del CONFERENCE_CACHE [ pk ] <EOL> except KeyError : <EOL> pass <EOL> class Meta ( object ) : <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> @ python_2_unicode_compatible <EOL> class Section ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> conference = models . ForeignKey ( Conference , verbose_name = _ ( "<STR_LIT>" ) ) <EOL> name = models . CharField ( _ ( "<STR_LIT:Name>" ) , max_length = <NUM_LIT:100> ) <EOL> slug = models . SlugField ( verbose_name = _ ( "<STR_LIT>" ) ) <EOL> start_date = models . DateField ( _ ( "<STR_LIT>" ) , null = True , blank = True ) <EOL> end_date = models . DateField ( _ ( "<STR_LIT>" ) , null = True , blank = True ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . conference , self . name ) <EOL> class Meta ( object ) : <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> ordering = [ "<STR_LIT>" ] <EOL> def current_conference ( ) : <EOL> from django . conf import settings <EOL> try : <EOL> conf_id = settings . CONFERENCE_ID <EOL> except AttributeError : <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> raise ImproperlyConfigured ( "<STR_LIT>" ) <EOL> try : <EOL> current_conf = CONFERENCE_CACHE [ conf_id ] <EOL> except KeyError : <EOL> current_conf = Conference . objects . get ( pk = conf_id ) <EOL> CONFERENCE_CACHE [ conf_id ] = current_conf <EOL> return current_conf </s>
