#NEWLINE# def render_ticket_action_control( self , req , ticket , action ) : #NEWLINE# #INDENT# self . log . debug ( 'render_ticket_action_control: action "%s"' , action ) #NEWLINE# this_action = self . actions [ action ] #NEWLINE# status = this_action [ 'newstate' ] #NEWLINE# operations = this_action [ 'operations' ] #NEWLINE# current_owner = ticket . _old . get ( 'owner' , ticket [ 'owner' ] ) #NEWLINE# author = get_reporter_id ( req , 'author' ) #NEWLINE# author_info = partial ( Chrome ( self . env ) . authorinfo , req , resource = ticket . resource ) #NEWLINE# format_author = partial ( Chrome ( self . env ) . format_author , req , resource = ticket . resource ) #NEWLINE# formatted_current_owner = author_info ( current_owner ) #NEWLINE# exists = ( ticket . _old . get ( 'status' , ticket [ 'status' ] ) is not None ) #NEWLINE# control = [ ] #NEWLINE# hints = [ ] #NEWLINE# if ( 'reset_workflow' in operations ) : #NEWLINE# #INDENT# control . append ( _ ( 'from invalid state' ) ) #NEWLINE# hints . append ( _ ( 'Current state no longer exists' ) ) #NEWLINE# #UNINDENT# if ( 'del_owner' in operations ) : #NEWLINE# #INDENT# hints . append ( _ ( 'The ticket will be disowned' ) ) #NEWLINE# #UNINDENT# if ( ( 'set_owner' in operations ) or ( 'may_set_owner' in operations ) ) : #NEWLINE# #INDENT# if ( 'set_owner' in this_action ) : #NEWLINE# #INDENT# owners = self . _to_users ( this_action [ 'set_owner' ] , ticket ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . config . getbool ( 'ticket' , 'restrict_owner' ) : #NEWLINE# #INDENT# perm = PermissionSystem ( self . env ) #NEWLINE# owners = perm . get_users_with_permission ( 'TICKET_MODIFY' ) #NEWLINE# owners = [ user for user in owners if ( 'TICKET_MODIFY' in PermissionCache ( self . env , user , ticket . resource ) ) ] #NEWLINE# owners = sorted ( owners ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# owners = None #NEWLINE# #UNINDENT# #UNINDENT# if ( 'set_owner' in operations ) : #NEWLINE# #INDENT# default_owner = author #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'may_set_owner' in operations ) : #NEWLINE# #INDENT# if ( not exists ) : #NEWLINE# #INDENT# default_owner = TicketSystem ( self . env ) . default_owner #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# default_owner = ticket . _old . get ( 'owner' , ( ticket [ 'owner' ] or None ) ) #NEWLINE# #UNINDENT# if ( ( owners is not None ) and ( default_owner not in owners ) ) : #NEWLINE# #INDENT# owners . insert ( 0 , default_owner ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise AssertionError ( operations ) #NEWLINE# #UNINDENT# #UNINDENT# id = ( 'action_%s_reassign_owner' % action ) #NEWLINE# if ( not owners ) : #NEWLINE# #INDENT# owner = req . args . get ( id , default_owner ) #NEWLINE# control . append ( tag_ ( 'to %(owner)s' , owner = tag . input ( type = 'text' , id = id , name = id , value = owner ) ) ) #NEWLINE# if ( ( not exists ) or ( current_owner is None ) ) : #NEWLINE# #INDENT# hints . append ( _ ( 'The owner will be the specified user' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# hints . append ( tag_ ( 'The owner will be changed from %(current_owner)s to the specified user' , current_owner = formatted_current_owner ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( owners ) == 1 ) : #NEWLINE# #INDENT# owner = tag . input ( type = 'hidden' , id = id , name = id , value = owners [ 0 ] ) #NEWLINE# formatted_new_owner = author_info ( owners [ 0 ] ) #NEWLINE# control . append ( tag_ ( 'to %(owner)s' , owner = tag ( formatted_new_owner , owner ) ) ) #NEWLINE# if ( ( not exists ) or ( current_owner is None ) ) : #NEWLINE# #INDENT# hints . append ( tag_ ( 'The owner will be %(new_owner)s' , new_owner = formatted_new_owner ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ticket [ 'owner' ] != owners [ 0 ] ) : #NEWLINE# #INDENT# hints . append ( tag_ ( 'The owner will be changed from %(current_owner)s to %(new_owner)s' , current_owner = formatted_current_owner , new_owner = formatted_new_owner ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# selected_owner = req . args . get ( id , default_owner ) #NEWLINE# control . append ( tag_ ( 'to %(owner)s' , owner = tag . select ( [ tag . option ( format_author ( x ) , value = ( x if ( x is not None ) else '' ) , selected = ( ( x == selected_owner ) or None ) ) for x in owners ] , id = id , name = id ) ) ) #NEWLINE# if ( ( not exists ) or ( current_owner is None ) ) : #NEWLINE# #INDENT# hints . append ( _ ( 'The owner will be the selected user' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# hints . append ( tag_ ( 'The owner will be changed from %(current_owner)s to the selected user' , current_owner = formatted_current_owner ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( 'set_owner_to_self' in operations ) and ( ticket . _old . get ( 'owner' , ticket [ 'owner' ] ) != author ) ) : #NEWLINE# #INDENT# formatted_author = author_info ( author ) #NEWLINE# if ( ( not exists ) or ( current_owner is None ) ) : #NEWLINE# #INDENT# hints . append ( tag_ ( 'The owner will be %(new_owner)s' , new_owner = formatted_author ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# hints . append ( tag_ ( 'The owner will be changed from %(current_owner)s to %(new_owner)s' , current_owner = formatted_current_owner , new_owner = formatted_author ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( 'set_resolution' in operations ) : #NEWLINE# #INDENT# if ( 'set_resolution' in this_action ) : #NEWLINE# #INDENT# resolutions = this_action [ 'set_resolution' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# resolutions = [ r . name for r in Resolution . select ( self . env ) ] #NEWLINE# #UNINDENT# if ( not resolutions ) : #NEWLINE# #INDENT# raise TracError ( _ ( 'Your workflow attempts to set a resolution but none is defined (configuration issue, please contact your Trac admin).' ) ) #NEWLINE# #UNINDENT# id = ( 'action_%s_resolve_resolution' % action ) #NEWLINE# if ( len ( resolutions ) == 1 ) : #NEWLINE# #INDENT# resolution = tag . input ( type = 'hidden' , id = id , name = id , value = resolutions [ 0 ] ) #NEWLINE# control . append ( tag_ ( 'as %(resolution)s' , resolution = tag ( resolutions [ 0 ] , resolution ) ) ) #NEWLINE# hints . append ( tag_ ( 'The resolution will be set to %(name)s' , name = resolutions [ 0 ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# selected_option = req . args . get ( id , TicketSystem ( self . env ) . default_resolution ) #NEWLINE# control . append ( tag_ ( 'as %(resolution)s' , resolution = tag . select ( [ tag . option ( x , value = x , selected = ( ( x == selected_option ) or None ) ) for x in resolutions ] , id = id , name = id ) ) ) #NEWLINE# hints . append ( _ ( 'The resolution will be set' ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'del_resolution' in operations ) : #NEWLINE# #INDENT# hints . append ( _ ( 'The resolution will be deleted' ) ) #NEWLINE# #UNINDENT# if ( 'leave_status' in operations ) : #NEWLINE# #INDENT# control . append ( tag_ ( 'as %(status)s' , status = ticket . _old . get ( 'status' , ticket [ 'status' ] ) ) ) #NEWLINE# if ( len ( operations ) == 1 ) : #NEWLINE# #INDENT# hints . append ( ( tag_ ( 'The owner will remain %(current_owner)s' , current_owner = formatted_current_owner ) if current_owner else _ ( 'The ticket will remain with no owner' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ticket [ 'status' ] is None ) : #NEWLINE# #INDENT# hints . append ( tag_ ( "The status will be '%(name)s'" , name = status ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( status != '*' ) : #NEWLINE# #INDENT# hints . append ( tag_ ( "Next status will be '%(name)s'" , name = status ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( this_action [ 'label' ] , tag ( separated ( control , ' ' ) ) , tag ( ( separated ( hints , '. ' , '.' ) if hints else '' ) ) )