<s> from genshi . builder import tag <EOL> from trac . core import implements , Component <EOL> from trac . ticket . api import ITicketActionController <EOL> from trac . ticket . default_workflow import ConfigurableTicketWorkflow <EOL> from trac . ticket . model import Priority , Ticket <EOL> revision = "<STR_LIT>" <EOL> url = "<STR_LIT>" <EOL> class VoteOperation ( Component ) : <EOL> """<STR_LIT>""" <EOL> implements ( ITicketActionController ) <EOL> def get_ticket_actions ( self , req , ticket ) : <EOL> controller = ConfigurableTicketWorkflow ( self . env ) <EOL> return controller . get_actions_by_operation_for_req ( req , ticket , '<STR_LIT>' ) <EOL> def get_all_status ( self ) : <EOL> return [ ] <EOL> def render_ticket_action_control ( self , req , ticket , action ) : <EOL> id = '<STR_LIT>' % ( action , ) <EOL> selected_value = req . args . get ( id , '<STR_LIT>' ) <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> return ( "<STR_LIT>" , <EOL> tag . select ( [ tag . option ( x , selected = ( x == selected_value or <EOL> None ) ) <EOL> for x in options ] , name = id , id = id ) , <EOL> "<STR_LIT>" ) <EOL> def get_ticket_changes ( self , req , ticket , action ) : <EOL> id = '<STR_LIT>' % ( action , ) <EOL> selected = req . args . get ( id , '<STR_LIT>' ) <EOL> priorities = list ( Priority . select ( self . env ) ) <EOL> orig_ticket = Ticket ( self . env , ticket . id ) <EOL> current_priority = int ( Priority ( self . env , name = <EOL> orig_ticket [ '<STR_LIT>' ] ) . value ) <EOL> if selected == '<STR_LIT>' : <EOL> new_value = max ( <NUM_LIT:1> , current_priority - <NUM_LIT:1> ) <EOL> else : <EOL> maxval = max ( [ int ( p . value ) for p in priorities ] ) <EOL> new_value = min ( maxval , current_priority + <NUM_LIT:1> ) <EOL> return { '<STR_LIT>' : [ p . name for p in priorities <EOL> if int ( p . value ) == new_value ] [ <NUM_LIT:0> ] } <EOL> def apply_action_side_effects ( self , req , ticket , action ) : <EOL> pass </s>
