#NEWLINE# def get_context_data( self , **kwargs ) : #NEWLINE# #INDENT# context = super ( BillableHours , self ) . get_context_data ( ** kwargs ) #NEWLINE# entries = context [ 'entries' ] #NEWLINE# date_headers = context [ 'date_headers' ] #NEWLINE# data_map = self . get_hours_data ( entries , date_headers ) #NEWLINE# from_date = context [ 'from_date' ] #NEWLINE# to_date = context [ 'to_date' ] #NEWLINE# trunc = context [ 'trunc' ] #NEWLINE# kwargs = { #NEWLINE# #INDENT# ( trunc + 's' ) : 1 , #NEWLINE# #UNINDENT# } #NEWLINE# keys = sorted ( data_map . keys ( ) ) #NEWLINE# data_list = [ [ 'Date' , 'Billable' , 'Non-billable' ] ] #NEWLINE# for i in range ( len ( keys ) ) : #NEWLINE# #INDENT# start = keys [ i ] #NEWLINE# start = ( start if ( start >= from_date ) else from_date ) #NEWLINE# end = ( ( start + relativedelta ( ** kwargs ) ) - relativedelta ( days = 1 ) ) #NEWLINE# end = ( end if ( end <= to_date ) else to_date ) #NEWLINE# if ( start != end ) : #NEWLINE# #INDENT# label = ' - ' . join ( [ date_format_filter ( d , 'M j' ) for d in ( start , end ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# label = date_format_filter ( start , 'M j' ) #NEWLINE# #UNINDENT# billable = data_map [ keys [ i ] ] [ 'billable' ] #NEWLINE# nonbillable = data_map [ keys [ i ] ] [ 'nonbillable' ] #NEWLINE# data_list . append ( [ label , billable , nonbillable ] ) #NEWLINE# #UNINDENT# context . update ( { #NEWLINE# #INDENT# 'data' : json . dumps ( data_list , cls = DecimalEncoder ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# return context