<s> from datetime import date <EOL> from django . core . paginator import EmptyPage , InvalidPage , Paginator <EOL> from django . core . urlresolvers import reverse <EOL> from django . contrib . sites . models import Site <EOL> from django . http import Http404 , HttpResponseRedirect , HttpResponsePermanentRedirect <EOL> from django . template import RequestContext <EOL> from django . shortcuts import get_object_or_404 , render_to_response <EOL> from django . utils . http import urlencode <EOL> from django . views . decorators . cache import cache_page <EOL> from brubeck . articles . models import Article <EOL> from brubeck . blogs . models import Blog , Entry <EOL> from brubeck . management . models import WebFront <EOL> from brubeck . multimedia . models import AudioClip , Slideshow , Video <EOL> from brubeck . podcasts . models import Channel , Episode <EOL> from brubeck . publishing . models import Issue , Section <EOL> from brubeck . tagging . models import Tag <EOL> @ cache_page ( <NUM_LIT> * <NUM_LIT:5> ) <EOL> def issue_archive ( request , page = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> page = int ( page ) <EOL> except ValueError : <EOL> raise Http404 <EOL> site = Site . objects . get_current ( ) <EOL> try : <EOL> issues = Issue . objects . filter ( volume__publication__site = site ) <EOL> except : <EOL> raise Http404 <EOL> archive_name = '<STR_LIT>' <EOL> paginator = Paginator ( issues , <NUM_LIT:20> ) <EOL> try : <EOL> archive_page = paginator . page ( page ) <EOL> except ( EmptyPage , InvalidPage ) : <EOL> raise Http404 <EOL> page = { <EOL> '<STR_LIT>' : archive_name , <EOL> '<STR_LIT>' : archive_page <EOL> } <EOL> return render_to_response ( '<STR_LIT>' , page , context_instance = RequestContext ( request ) ) <EOL> @ cache_page ( <NUM_LIT> * <NUM_LIT:5> ) <EOL> def issue_detail ( request , id = None , page = None ) : <EOL> """<STR_LIT>""" <EOL> issue = get_object_or_404 ( Issue , id = int ( id ) ) <EOL> if page : <EOL> HttpResponsePermanentRedirect ( issue . get_absolute_url ( ) ) <EOL> images = [ ] <EOL> images . extend ( issue . photo_set . all ( ) ) <EOL> images . extend ( issue . graphic_set . all ( ) ) <EOL> comics = issue . comicepisode_set . all ( ) <EOL> games = issue . gameanswer_set . all ( ) <EOL> page = { <EOL> '<STR_LIT>' : comics , <EOL> '<STR_LIT>' : games , <EOL> '<STR_LIT>' : images , <EOL> '<STR_LIT>' : issue <EOL> } <EOL> return render_to_response ( '<STR_LIT>' , page , context_instance = RequestContext ( request ) ) <EOL> def section_archive ( request , slug = None , page = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> site = Site . objects . get_current ( ) <EOL> try : <EOL> section = Section . objects . filter ( publication__site = site ) . get ( slug = slug ) <EOL> except Section . DoesNotExist : <EOL> raise Http404 <EOL> archive_name = section . name <EOL> try : <EOL> page = int ( page ) <EOL> except ValueError : <EOL> raise Http404 <EOL> articles = Article . get_published . filter ( section = section ) <EOL> paginator = Paginator ( articles , <NUM_LIT:20> ) <EOL> try : <EOL> archive_page = paginator . page ( page ) <EOL> except ( EmptyPage , InvalidPage ) : <EOL> raise Http404 <EOL> next_page_url = '<STR_LIT>' % ( slug , page + <NUM_LIT:1> ) <EOL> previous_page_url = '<STR_LIT>' % ( slug , page - <NUM_LIT:1> ) <EOL> page = { <EOL> '<STR_LIT>' : archive_name , <EOL> '<STR_LIT>' : archive_page , <EOL> '<STR_LIT>' : next_page_url , <EOL> '<STR_LIT>' : previous_page_url , <EOL> '<STR_LIT>' : section <EOL> } <EOL> return render_to_response ( '<STR_LIT>' , page , RequestContext ( request ) ) </s>
