#NEWLINE# def __init__( self , * args , **kw ) : #NEWLINE# #INDENT# self . helper = kw . pop ( 'helper' ) #NEWLINE# self . type = kw . pop ( 'type' , amo . CANNED_RESPONSE_ADDON ) #NEWLINE# super ( ReviewForm , self ) . __init__ ( * args , ** kw ) #NEWLINE# canned_choices = [ [ '' , [ ( '' , _ ( 'Choose a canned response...' ) ) ] ] ] #NEWLINE# responses = CannedResponse . objects . filter ( type = self . type ) #NEWLINE# for ( k , action ) in self . helper . actions . iteritems ( ) : #NEWLINE# #INDENT# action_choices = [ [ c . response , c . name ] for c in responses if ( c . sort_group and ( k in c . sort_group . split ( ',' ) ) ) ] #NEWLINE# if action_choices : #NEWLINE# #INDENT# canned_choices . append ( [ action [ 'label' ] , action_choices ] ) #NEWLINE# #UNINDENT# #UNINDENT# for r in responses : #NEWLINE# #INDENT# if ( not r . sort_group ) : #NEWLINE# #INDENT# canned_choices . append ( [ r . response , r . name ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . fields [ 'canned_response' ] . choices = canned_choices #NEWLINE# self . fields [ 'action' ] . choices = [ ( k , v [ 'label' ] ) for ( k , v ) in self . helper . actions . items ( ) ]