#NEWLINE# def pag_story_detail( request , year , month , day , slug , p_per_page = settings . PAGINATION [ 'P_PER_PAGE' ] , orphans = settings . PAGINATION [ 'ORPHANS' ] , p_object_name = 'story_content' , template_object_name = 'story' , template_name = 'stories/pag_story.html' , extra_context = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# '\n    A detail view for stories that can paginates the story by paragraph.\n    If a story is not found a 404 or a custom template can be rendered\n    by setting `THROW_404` to `False`.\n\n    By default, template `stories/pag_story.html` is used to render the\n    story which expects the story to be paginated by paragraphs. If the\n    paragraph paginator is not used, the template `stories/story_detail.html`\n    is used to render the story.\n\n    There is two main variables passed to the template `p_object_name`, which\n    is the stories body field, and `template_object_name` which is the\n    story instance it self.\n\n    Argument List:\n\n    * **year** - Four digets, `2012`, `1997`, `2004`\n    * **month** - `jul` `jan` `aug`\n    * **day** - Two digits, `01` `23`, `31`\n    * **slug** - slugified string, `this-is-a-slug`\n    * **p_per_page** - pagination setting, paragraphs per page\n    * **orphans** - pagination setting, number of orphans\n    * **p_object_name** - the story body variable name\n    * **template_object_name** - the story variable name\n    * **template_name** - the name of the template\n    * **extra_context** - dictionary containing any extra context\n    ' #NEWLINE# import datetime #NEWLINE# import time #NEWLINE# try : #NEWLINE# #INDENT# pub_date = datetime . date ( * time . strptime ( ( ( year + month ) + day ) , '%Y%b%d' ) [ : 3 ] ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise Http404 #NEWLINE# #UNINDENT# qs = Story . published . get #NEWLINE# if request . user . is_staff : #NEWLINE# #INDENT# qs = Story . objects . get #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# story = qs ( publish_date = pub_date , slug = slug ) #NEWLINE# #UNINDENT# except Story . DoesNotExist : #NEWLINE# #INDENT# if ( not settings . THROW_404 ) : #NEWLINE# #INDENT# return render_to_response ( 'stories/story_removed.html' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , context_instance = RequestContext ( request ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Http404 #NEWLINE# #UNINDENT# #UNINDENT# if settings . PAGINATION [ 'PAGINATE' ] : #NEWLINE# #INDENT# paginator = ParagraphPaginator ( story . body , p_per_page , orphans = orphans ) #NEWLINE# try : #NEWLINE# #INDENT# page = int ( request . GET . get ( 'page' , '1' ) ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# page = 1 #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# story_content = paginator . page ( page ) #NEWLINE# #UNINDENT# except ( EmptyPage , InvalidPage ) : #NEWLINE# #INDENT# story_content = paginator . page ( paginator . num_pages ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# story_content = story . body #NEWLINE# if ( template_name == 'stories/pag_story.html' ) : #NEWLINE# #INDENT# template_name = 'stories/story_detail.html' #NEWLINE# #UNINDENT# #UNINDENT# context = { #NEWLINE# #INDENT# p_object_name : story_content , #NEWLINE# template_object_name : story , #NEWLINE# #UNINDENT# } #NEWLINE# if extra_context : #NEWLINE# #INDENT# context . update ( extra_context ) #NEWLINE# #UNINDENT# return render_to_response ( template_name , context , context_instance = RequestContext ( request ) )