#NEWLINE# @ cache_page ( ( 60 * 30 ) ) #NEWLINE# def archive( request , slug = None , year = None , month = None , day = None , page = 1 ) : #NEWLINE# #INDENT# 'Show a paginated, optionally date-based archive of comic episodes.' #NEWLINE# if year : #NEWLINE# #INDENT# year = int ( year ) #NEWLINE# #UNINDENT# if month : #NEWLINE# #INDENT# month = int ( month ) #NEWLINE# #UNINDENT# if day : #NEWLINE# #INDENT# day = int ( day ) #NEWLINE# #UNINDENT# if ( year and ( year < 2008 ) ) : #NEWLINE# #INDENT# episode = ComicEpisode . objects . get ( id = year ) #NEWLINE# return HttpResponsePermanentRedirect ( ( '/comics/%s/%s/%s/%s/%s/' % ( episode . strip . slug , episode . pub_date . year , episode . pub_date . month , episode . pub_date . day , episode . id ) ) ) #NEWLINE# #UNINDENT# strip = ComicStrip . objects . filter ( slug = slug ) [ 0 ] #NEWLINE# images = ComicEpisode . objects . filter ( strip__slug = slug ) #NEWLINE# if ( not year ) : #NEWLINE# #INDENT# images = images #NEWLINE# archive_name = ( '%s' % strip . title ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not month ) : #NEWLINE# #INDENT# images = images . filter ( pub_date__year = year ) #NEWLINE# archive_name = ( '%s episodes from %s' % ( strip . title , year ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not day ) : #NEWLINE# #INDENT# images = images . filter ( pub_date__year = year , pub_date__month = month ) #NEWLINE# archive_name = ( '%s episodes from %s' % ( strip . title , date ( year , month , 1 ) . strftime ( '%B %Y' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# images = images . filter ( pub_date = date ( year , month , day ) ) #NEWLINE# archive_name = ( '%s episodes from %s' % ( strip . title , date ( year , month , day ) . strftime ( '%B %d, %Y' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# paginator = Paginator ( images , 10 ) #NEWLINE# try : #NEWLINE# #INDENT# archive_page = paginator . page ( page ) #NEWLINE# #UNINDENT# except ( EmptyPage , InvalidPage ) : #NEWLINE# #INDENT# raise Http404 #NEWLINE# #UNINDENT# page = { #NEWLINE# #INDENT# 'archive_name' : archive_name , #NEWLINE# 'archive_page' : archive_page , #NEWLINE# #UNINDENT# } #NEWLINE# return render_to_response ( 'core/archive.html' , page , context_instance = RequestContext ( request ) )