<s> """<STR_LIT>""" <EOL> from django . utils import timezone <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from django . views . generic . base import TemplateResponseMixin <EOL> class EntryQuerysetTemplateResponseMixin ( TemplateResponseMixin ) : <EOL> """<STR_LIT>""" <EOL> model_type = None <EOL> model_name = None <EOL> def get_model_type ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . model_type is None : <EOL> raise ImproperlyConfigured ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> self . __class__ . __name__ ) <EOL> return self . model_type <EOL> def get_model_name ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . model_name is None : <EOL> raise ImproperlyConfigured ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> self . __class__ . __name__ ) <EOL> return self . model_name <EOL> def get_template_names ( self ) : <EOL> """<STR_LIT>""" <EOL> model_type = self . get_model_type ( ) <EOL> model_name = self . get_model_name ( ) <EOL> templates = [ <EOL> '<STR_LIT>' % ( model_type , model_name ) , <EOL> '<STR_LIT>' % ( model_type , model_name ) , <EOL> '<STR_LIT>' % model_type , <EOL> '<STR_LIT>' ] <EOL> if self . template_name is not None : <EOL> templates . insert ( <NUM_LIT:0> , self . template_name ) <EOL> return templates <EOL> class EntryQuerysetArchiveTemplateResponseMixin ( TemplateResponseMixin ) : <EOL> """<STR_LIT>""" <EOL> template_name_suffix = '<STR_LIT>' <EOL> def get_archive_part_value ( self , part ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return getattr ( self , '<STR_LIT>' % part ) ( ) <EOL> except AttributeError : <EOL> return None <EOL> def get_default_base_template_names ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ '<STR_LIT>' % self . template_name_suffix ] <EOL> def get_template_names ( self ) : <EOL> """<STR_LIT>""" <EOL> year = self . get_archive_part_value ( '<STR_LIT>' ) <EOL> week = self . get_archive_part_value ( '<STR_LIT>' ) <EOL> month = self . get_archive_part_value ( '<STR_LIT>' ) <EOL> day = self . get_archive_part_value ( '<STR_LIT>' ) <EOL> templates = [ ] <EOL> path = '<STR_LIT>' <EOL> template_names = self . get_default_base_template_names ( ) <EOL> for template_name in template_names : <EOL> templates . extend ( [ template_name , <EOL> '<STR_LIT>' % template_name , <EOL> '<STR_LIT>' % ( path , template_name ) ] ) <EOL> if year : <EOL> for template_name in template_names : <EOL> templates . append ( <EOL> '<STR_LIT>' % ( path , year , template_name ) ) <EOL> if week : <EOL> for template_name in template_names : <EOL> templates . extend ( [ <EOL> '<STR_LIT>' % ( path , week , template_name ) , <EOL> '<STR_LIT>' % ( path , year , week , template_name ) ] ) <EOL> if month : <EOL> for template_name in template_names : <EOL> templates . extend ( [ <EOL> '<STR_LIT>' % ( path , month , template_name ) , <EOL> '<STR_LIT>' % ( path , year , month , template_name ) ] ) <EOL> if day : <EOL> for template_name in template_names : <EOL> templates . extend ( [ <EOL> '<STR_LIT>' % ( path , day , template_name ) , <EOL> '<STR_LIT>' % ( path , year , day , template_name ) , <EOL> '<STR_LIT>' % ( path , month , day , <EOL> template_name ) , <EOL> '<STR_LIT>' % ( path , year , month , day , <EOL> template_name ) ] ) <EOL> if self . template_name is not None : <EOL> templates . append ( self . template_name ) <EOL> templates . reverse ( ) <EOL> return templates <EOL> class EntryArchiveTemplateResponseMixin ( <EOL> EntryQuerysetArchiveTemplateResponseMixin ) : <EOL> """<STR_LIT>""" <EOL> def get_default_base_template_names ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ self . object . detail_template , <EOL> '<STR_LIT>' % self . object . slug , <EOL> '<STR_LIT>' % ( self . object . slug , self . object . detail_template ) ] <EOL> class EntryQuerysetArchiveTodayTemplateResponseMixin ( <EOL> EntryQuerysetArchiveTemplateResponseMixin ) : <EOL> """<STR_LIT>""" <EOL> today = None <EOL> def get_archive_part_value ( self , part ) : <EOL> """<STR_LIT>""" <EOL> parts_dict = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . month_format , <EOL> '<STR_LIT>' : self . week_format , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> if self . today is None : <EOL> today = timezone . now ( ) <EOL> if timezone . is_aware ( today ) : <EOL> today = timezone . localtime ( today ) <EOL> self . today = today <EOL> return self . today . strftime ( parts_dict [ part ] ) </s>
