<s> from nagare . i18n import _ <EOL> from nagare import ajax , presentation <EOL> from . comp import CardWeightEditor <EOL> def answer ( editor , comp ) : <EOL> if editor . commit ( ) : <EOL> comp . answer ( ) <EOL> @ presentation . render_for ( CardWeightEditor , '<STR_LIT:action>' ) <EOL> def render_cardweighteditor ( self , h , comp , * args ) : <EOL> if self . weighting_switch : <EOL> h << self . action_button <EOL> return h . root <EOL> @ presentation . render_for ( CardWeightEditor , '<STR_LIT>' ) <EOL> def render_CardWeightEditor_action_button ( self , h , comp , * args ) : <EOL> h << h . a ( h . i ( class_ = '<STR_LIT>' ) , self . weight , class_ = '<STR_LIT>' ) . action ( <EOL> comp . call , self , model = '<STR_LIT>' ) <EOL> return h . root <EOL> @ presentation . render_for ( CardWeightEditor , '<STR_LIT>' ) <EOL> def render_CardWeightEditor_edit ( self , h , comp , * args ) : <EOL> if self . weighting_switch == self . WEIGHTING_FREE : <EOL> id_ = h . generate_id ( '<STR_LIT>' ) <EOL> with h . form : <EOL> h << h . input ( <EOL> value = self . weight ( ) , <EOL> type = '<STR_LIT:text>' , <EOL> id_ = id_ ) . action ( self . weight ) . error ( self . weight . error ) <EOL> h << h . button ( _ ( '<STR_LIT>' ) , class_ = '<STR_LIT>' ) . action ( answer , self , comp ) <EOL> h << h . script ( """<STR_LIT>""" % ajax . py2js ( id_ ) ) <EOL> elif self . weighting_switch == self . WEIGHTING_LIST : <EOL> with h . form : <EOL> with h . div ( class_ = '<STR_LIT>' ) : <EOL> with h . select . action ( self . weight ) : <EOL> for value in self . allowed_weights . split ( '<STR_LIT:U+002C>' ) : <EOL> h << h . option ( value , value = value ) . selected ( self . weight ) <EOL> h << h . button ( _ ( '<STR_LIT>' ) , class_ = '<STR_LIT>' ) . action ( answer , self , comp ) <EOL> return h . root <EOL> @ presentation . render_for ( CardWeightEditor , '<STR_LIT>' ) <EOL> def render_CardWeightEditor_badge ( self , h , comp , * args ) : <EOL> if self . weight . value : <EOL> with h . span ( class_ = '<STR_LIT>' ) : <EOL> h << h . span ( h . i ( class_ = '<STR_LIT>' ) , '<STR_LIT:U+0020>' , <EOL> self . weight . value , class_ = '<STR_LIT:label>' , title = _ ( u'<STR_LIT>' ) ) <EOL> return h . root </s>
