<s> from django import forms <EOL> from django . forms . widgets import TextInput , CheckboxSelectMultiple , ChoiceFieldRenderer , ChoiceInput , CheckboxChoiceInput , RadioSelect <EOL> from django . utils . encoding import force_text <EOL> from django . utils . html import format_html <EOL> from django . utils . safestring import mark_safe <EOL> class NameSuggestInput ( TextInput ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> self . suggest_fields = kwargs . pop ( '<STR_LIT>' ) <EOL> self . separator = kwargs . pop ( '<STR_LIT>' , '<STR_LIT:->' ) <EOL> super ( NameSuggestInput , self ) . __init__ ( * args , ** kwargs ) <EOL> def render ( self , name , value , attrs = None ) : <EOL> out = super ( NameSuggestInput , self ) . render ( name , value , attrs ) <EOL> if self . suggest_fields : <EOL> button = u"<STR_LIT>" . format ( self . separator , "<STR_LIT:U+002C>" . join ( self . suggest_fields ) ) <EOL> out = u"<STR_LIT>" . format ( out , button ) <EOL> return mark_safe ( out ) <EOL> class RegistrationAuthoritySelect ( forms . Select ) : <EOL> def render ( self , name , value , attrs = None , choices = ( ) ) : <EOL> if value is not None : <EOL> attrs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> _id = attrs . get ( '<STR_LIT:id>' ) <EOL> hidden_input_with_value = '<STR_LIT>' % ( _id , name , value ) <EOL> attrs [ '<STR_LIT:id>' ] = _id + "<STR_LIT>" <EOL> name = name + "<STR_LIT>" <EOL> rendered = super ( RegistrationAuthoritySelect , self ) . render ( name , value , attrs , choices ) <EOL> return mark_safe ( rendered + hidden_input_with_value ) <EOL> else : <EOL> return super ( RegistrationAuthoritySelect , self ) . render ( name , value , attrs , choices ) <EOL> class BootstrapChoiceInput ( ChoiceInput ) : <EOL> input_type = '<STR_LIT>' <EOL> def render ( self , name = None , value = None , attrs = None , choices = ( ) ) : <EOL> name = name or self . name <EOL> value = value or self . value <EOL> attrs = attrs or self . attrs <EOL> if '<STR_LIT:id>' in self . attrs : <EOL> label_for = format_html ( u'<STR_LIT>' , self . attrs [ '<STR_LIT:id>' ] ) <EOL> else : <EOL> label_for = '<STR_LIT>' <EOL> return format_html ( u'<STR_LIT>' , label_for , self . tag ( ) , self . choice_label ) <EOL> def tag ( self ) : <EOL> self . attrs [ '<STR_LIT>' ] = - <NUM_LIT:1> <EOL> return super ( BootstrapChoiceInput , self ) . tag ( ) <EOL> class BootstrapCheckInput ( BootstrapChoiceInput , CheckboxChoiceInput ) : <EOL> input_type = '<STR_LIT>' <EOL> class BootstrapChoiceFieldRenderer ( ChoiceFieldRenderer ) : <EOL> wrap = True <EOL> choice_input_class = BootstrapChoiceInput <EOL> def render ( self ) : <EOL> """<STR_LIT>""" <EOL> id_ = self . attrs . get ( '<STR_LIT:id>' , None ) <EOL> output = [ ] <EOL> for widget in self : <EOL> output . append ( format_html ( u'<STR_LIT>' , force_text ( widget ) ) ) <EOL> if self . wrap : <EOL> start_tag = format_html ( u'<STR_LIT>' , id_ ) if id_ else '<STR_LIT>' <EOL> output = [ start_tag ] + output <EOL> output . append ( u'<STR_LIT>' ) <EOL> return mark_safe ( '<STR_LIT:\n>' . join ( output ) ) <EOL> class BootstrapCheckboxFieldRenderer ( BootstrapChoiceFieldRenderer ) : <EOL> choice_input_class = BootstrapCheckInput <EOL> class BootstrapRadioFieldRenderer ( BootstrapChoiceFieldRenderer ) : <EOL> choice_input_class = BootstrapChoiceInput <EOL> class BootstrapIntelligentDateRenderer ( BootstrapChoiceFieldRenderer ) : <EOL> choice_input_class = BootstrapChoiceInput <EOL> wrap = False <EOL> class BootstrapDropdownSelect ( RadioSelect ) : <EOL> renderer = BootstrapRadioFieldRenderer <EOL> allow_multiple_selected = False <EOL> class BootstrapDropdownIntelligentDate ( BootstrapDropdownSelect ) : <EOL> renderer = BootstrapIntelligentDateRenderer <EOL> class BootstrapDropdownSelectMultiple ( CheckboxSelectMultiple ) : <EOL> renderer = BootstrapCheckboxFieldRenderer <EOL> allow_multiple_selected = True </s>
