#NEWLINE# def day( request , year , month , day , queryset = None , recent_first = False , template_name = 'jellyroll/calendar/day.html' , template_loader = loader , extra_context = None , context_processors = None , mimetype = None ) : #NEWLINE# #INDENT# "\n    Jellyroll'd items for a particular day.\n\n    Works a bit like a generic view in that you can pass a bunch of optional\n    keyword arguments which work just like they do in generic views. Those\n    arguments are: ``template_name``, ``template_loader``, ``extra_context``,\n    ``context_processors``, and ``mimetype``.\n    \n    Also takes a ``recent_first`` param; if it's ``True`` the newest items\n    will be displayed first; otherwise items will be ordered earliest first.\n\n    You can also pass a ``queryset`` argument; see the module's docstring\n    for information about how that works.\n\n    Templates: ``jellyroll/calendar/day.html`` (default)\n    Context:\n        ``items``\n            Items from the month, ordered according to ``recent_first``.\n        ``day``\n            The day (a ``datetime.date`` object).\n        ``previous``\n            The previous day; ``None`` if that day was before jellyrolling\n            started.\n        ``previous_link``\n            Link to the previous day\n        ``next``\n            The next day; ``None`` if it's in the future.\n        ``next_link``\n            Link to the next day.\n        ``is_today``\n            ``True`` if this day is today.\n    " #NEWLINE# try : #NEWLINE# #INDENT# day = datetime . date ( * time . strptime ( ( ( year + month ) + day ) , '%Y%b%d' ) [ : 3 ] ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise Http404 ( 'Invalid day string' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# first = Item . objects . order_by ( 'timestamp' ) [ 0 ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# raise Http404 ( 'No items; no views.' ) #NEWLINE# #UNINDENT# today = datetime . date . today ( ) #NEWLINE# if ( ( day < first . timestamp . date ( ) ) or ( day > today ) ) : #NEWLINE# #INDENT# raise Http404 ( ( 'Invalid day (%s .. %s)' % ( first . timestamp . date ( ) , today ) ) ) #NEWLINE# #UNINDENT# previous = ( day - datetime . timedelta ( days = 1 ) ) #NEWLINE# previous_link = urlresolvers . reverse ( 'jellyroll.views.calendar.day' , args = previous . strftime ( '%Y %b %d' ) . lower ( ) . split ( ) ) #NEWLINE# if ( previous < first . timestamp . date ( ) ) : #NEWLINE# #INDENT# previous = previous_link = None #NEWLINE# #UNINDENT# next = ( day + datetime . timedelta ( days = 1 ) ) #NEWLINE# next_link = urlresolvers . reverse ( 'jellyroll.views.calendar.day' , args = next . strftime ( '%Y %b %d' ) . lower ( ) . split ( ) ) #NEWLINE# if ( next > today ) : #NEWLINE# #INDENT# next = next_link = None #NEWLINE# #UNINDENT# timestamp_range = ( datetime . datetime . combine ( day , datetime . time . min ) , datetime . datetime . combine ( day , datetime . time . max ) ) #NEWLINE# if ( not queryset ) : #NEWLINE# #INDENT# queryset = Item . objects . all ( ) #NEWLINE# #UNINDENT# queryset = queryset . filter ( timestamp__range = timestamp_range ) #NEWLINE# if ( not queryset . query . order_by ) : #NEWLINE# #INDENT# if recent_first : #NEWLINE# #INDENT# queryset = queryset . order_by ( '-timestamp' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# queryset = queryset . order_by ( 'timestamp' ) #NEWLINE# #UNINDENT# #UNINDENT# context = RequestContext ( request , { #NEWLINE# #INDENT# 'items' : queryset , #NEWLINE# 'day' : day , #NEWLINE# 'previous' : previous , #NEWLINE# 'previous_link' : previous_link , #NEWLINE# 'next' : next , #NEWLINE# 'next_link' : next_link , #NEWLINE# 'is_today' : ( day == today ) , #NEWLINE# #UNINDENT# } , context_processors ) #NEWLINE# if extra_context : #NEWLINE# #INDENT# for ( key , value ) in extra_context . items ( ) : #NEWLINE# #INDENT# if callable ( value ) : #NEWLINE# #INDENT# context [ key ] = value ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# context [ key ] = value #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# t = template_loader . get_template ( template_name ) #NEWLINE# return HttpResponse ( t . render ( context ) , mimetype = mimetype )