#NEWLINE# def calendar_view( request , year = datetime . now ( ) . year , month = datetime . now ( ) . month , channel_slug = None , page = 1 ) : #NEWLINE# #INDENT# '\n    Shows a grid (similar in appearance to a physical calendar) of podcasts for either a specific podcast channel or no\n    channel at all.  Based on the GridOne layout originally developed for Calendars.\n    ' #NEWLINE# site = Site . objects . get_current ( ) #NEWLINE# try : #NEWLINE# #INDENT# page = int ( page ) #NEWLINE# if year : #NEWLINE# #INDENT# year = int ( year ) #NEWLINE# #UNINDENT# if month : #NEWLINE# #INDENT# month = int ( month ) #NEWLINE# #UNINDENT# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise Http404 #NEWLINE# #UNINDENT# channel = None #NEWLINE# channel_list = Channel . current . filter ( section__publication__site = site ) . order_by ( 'title' ) #NEWLINE# episodes = Episode . objects . filter ( channel__section__publication__site = site ) #NEWLINE# if channel_slug : #NEWLINE# #INDENT# channel = get_object_or_404 ( Channel , slug = channel_slug ) #NEWLINE# episodes = episodes . filter ( channel = channel ) #NEWLINE# #UNINDENT# month_formatted = pycal . monthcalendar ( year , month ) #NEWLINE# month_minus = ( month - 1 ) #NEWLINE# month_plus = ( month + 1 ) #NEWLINE# month_name = pycal . month_name [ month ] #NEWLINE# weekday_header = pycal . weekheader ( 3 ) . strip ( ) . split ( ' ' ) #NEWLINE# year_minus = ( year - 1 ) #NEWLINE# year_plus = ( year + 1 ) #NEWLINE# today = datetime . now ( ) . day #NEWLINE# this_month = datetime . now ( ) . month #NEWLINE# this_year = datetime . now ( ) . year #NEWLINE# episode_list = episodes . filter ( pub_date__year = year ) . filter ( pub_date__month = month ) #NEWLINE# page_name = 'This is a test of the calendaring system.' #NEWLINE# page = { #NEWLINE# #INDENT# 'channel' : channel , #NEWLINE# 'channel_list' : channel_list , #NEWLINE# 'episode_list' : episode_list , #NEWLINE# 'month' : month , #NEWLINE# 'month_formatted' : month_formatted , #NEWLINE# 'month_minus' : month_minus , #NEWLINE# 'month_name' : month_name , #NEWLINE# 'month_plus' : month_plus , #NEWLINE# 'page_name' : page_name , #NEWLINE# 'site' : site , #NEWLINE# 'this_month' : this_month , #NEWLINE# 'this_year' : this_year , #NEWLINE# 'today' : today , #NEWLINE# 'weekday_header' : weekday_header , #NEWLINE# 'year' : year , #NEWLINE# 'year_minus' : year_minus , #NEWLINE# 'year_plus' : year_plus , #NEWLINE# #UNINDENT# } #NEWLINE# return render_to_response ( 'podcasts/calendar.html' , page , context_instance = RequestContext ( request ) )