#NEWLINE# def get_context_data( self , **kwargs ) : #NEWLINE# #INDENT# context = super ( Dashboard , self ) . get_context_data ( ** kwargs ) #NEWLINE# has_one_window = False #NEWLINE# next_window = None #NEWLINE# launch_windows = LaunchWindow . objects . all ( ) #NEWLINE# for window in launch_windows : #NEWLINE# #INDENT# current_date = datetime . now ( ) #NEWLINE# next_window = croniter ( window . cron_format , current_date ) . get_next ( datetime ) #NEWLINE# if ( ( next_window - datetime . now ( ) ) . seconds < 61 ) : #NEWLINE# #INDENT# has_one_window = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( ( not has_one_window ) and launch_windows . exists ( ) ) : #NEWLINE# #INDENT# messages . add_message ( self . request , messages . ERROR , ( 'No available Launch Windows! Next window on %s @ %s' % ( format_date ( next_window ) , format_time ( next_window ) ) ) ) #NEWLINE# #UNINDENT# deployments = Deployment . active_records . order_by ( 'status' ) . values ( 'status' ) . annotate ( count = Count ( 'id' ) ) #NEWLINE# items = ( [ [ 'string' , 'number' ] ] + [ [ item [ 'status' ] , item [ 'count' ] ] for item in deployments ] ) #NEWLINE# context [ 'pie_chart' ] = PieChart ( SimpleDataSource ( items ) , width = '100%' , height = 300 , options = { #NEWLINE# #INDENT# 'title' : '' , #NEWLINE# #UNINDENT# } ) #NEWLINE# chart_data = [ ] #NEWLINE# projects = list ( Project . active_records . all ( ) ) #NEWLINE# if ( len ( projects ) == 0 ) : #NEWLINE# #INDENT# return context #NEWLINE# #UNINDENT# deploys = list ( Deployment . objects . select_related ( 'stage' ) . order_by ( 'date_created' ) ) #NEWLINE# start_date = ( timezone . now ( ) - timedelta ( days = 60 ) ) . date ( ) #NEWLINE# end_date = timezone . now ( ) . date ( ) #NEWLINE# for day in range ( ( - 1 ) , ( ( end_date - start_date ) . days + 1 ) ) : #NEWLINE# #INDENT# date = ( start_date + timedelta ( days = day ) ) #NEWLINE# if ( day == ( - 1 ) ) : #NEWLINE# #INDENT# data = [ 'Day' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data = [ date . strftime ( '%m/%d' ) ] #NEWLINE# #UNINDENT# for project in projects : #NEWLINE# #INDENT# if ( day == ( - 1 ) ) : #NEWLINE# #INDENT# data . append ( project . name ) #NEWLINE# continue #NEWLINE# #UNINDENT# count = 0 #NEWLINE# for d in deploys : #NEWLINE# #INDENT# if ( ( d . stage . project_id == project . pk ) and ( d . date_created . date ( ) == date ) ) : #NEWLINE# #INDENT# count += 1 #NEWLINE# #UNINDENT# #UNINDENT# data . append ( count ) #NEWLINE# #UNINDENT# chart_data . append ( data ) #NEWLINE# #UNINDENT# context [ 'line_chart' ] = LineChart ( SimpleDataSource ( chart_data ) , width = '100%' , height = 300 , options = { #NEWLINE# #INDENT# 'title' : '' , #NEWLINE# #UNINDENT# } ) #NEWLINE# return context