#NEWLINE# @ register . inclusion_tag ( 'partial/execution_list_inline.html' , takes_context = True ) #NEWLINE# def last_activity_bar( context , related_to = None , no_title = False ) : #NEWLINE# #INDENT# if ( not related_to ) : #NEWLINE# #INDENT# raise Exception ( 'related_to parameter is required' ) #NEWLINE# #UNINDENT# data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# query = Execution . objects #NEWLINE# class_name = related_to . __class__ . __name__ #NEWLINE# if ( class_name == 'Application' ) : #NEWLINE# #INDENT# query = query . filter ( environment__application = related_to , environment__in = context [ 'allowed_environments' ] , task__in = context [ 'allowed_tasks' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( class_name == 'Environment' ) : #NEWLINE# #INDENT# query = query . filter ( environment = related_to , task__in = context [ 'allowed_tasks' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( class_name == 'Task' ) : #NEWLINE# #INDENT# query = query . filter ( task = related_to , environment__in = context [ 'allowed_environments' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( class_name == 'CustomUser' ) : #NEWLINE# #INDENT# query = query . filter ( user = related_to , environment__in = context [ 'allowed_environments' ] , task__in = context [ 'allowed_tasks' ] ) #NEWLINE# class_name = 'User' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# data [ 'list' ] = query . order_by ( '-time_created' ) [ : 4 ] #NEWLINE# data [ 'model_name' ] = class_name . lower ( ) #NEWLINE# data [ 'related_to' ] = related_to #NEWLINE# data [ 'no_title' ] = no_title #NEWLINE# return data