#NEWLINE# def get_kwargs( self , field , kwargs ) : #NEWLINE# #INDENT# '\n            Return extra kwargs based on the field type.\n        ' #NEWLINE# if ( field . type == 'StringField' ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'text' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( field . type == 'TextAreaField' ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'textarea' #NEWLINE# kwargs [ 'data-rows' ] = '5' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( field . type == 'BooleanField' ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'select' #NEWLINE# kwargs [ 'data-source' ] = json . dumps ( [ { #NEWLINE# #INDENT# 'value' : '' , #NEWLINE# 'text' : gettext ( 'No' ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'value' : '1' , #NEWLINE# 'text' : gettext ( 'Yes' ) , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# kwargs [ 'data-role' ] = 'x-editable-boolean' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( field . type == 'Select2Field' ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'select' #NEWLINE# choices = [ { #NEWLINE# #INDENT# 'value' : x , #NEWLINE# 'text' : y , #NEWLINE# #UNINDENT# } for ( x , y ) in field . choices ] #NEWLINE# if getattr ( field , 'allow_blank' , False ) : #NEWLINE# #INDENT# choices . insert ( 0 , { #NEWLINE# #INDENT# 'value' : '__None' , #NEWLINE# 'text' : '' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# kwargs [ 'data-source' ] = json . dumps ( choices ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( field . type == 'DateField' ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'combodate' #NEWLINE# kwargs [ 'data-format' ] = 'YYYY-MM-DD' #NEWLINE# kwargs [ 'data-template' ] = 'YYYY-MM-DD' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( field . type == 'DateTimeField' ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'combodate' #NEWLINE# kwargs [ 'data-format' ] = 'YYYY-MM-DD HH:mm:ss' #NEWLINE# kwargs [ 'data-template' ] = 'YYYY-MM-DD  HH:mm:ss' #NEWLINE# kwargs [ 'data-role' ] = 'x-editable-combodate' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( field . type == 'TimeField' ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'combodate' #NEWLINE# kwargs [ 'data-format' ] = 'HH:mm:ss' #NEWLINE# kwargs [ 'data-template' ] = 'HH:mm:ss' #NEWLINE# kwargs [ 'data-role' ] = 'x-editable-combodate' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( field . type == 'IntegerField' ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'number' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( field . type in [ 'FloatField' , 'DecimalField' ] ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'number' #NEWLINE# kwargs [ 'data-step' ] = 'any' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( field . type in [ 'QuerySelectField' , 'ModelSelectField' , 'QuerySelectMultipleField' ] ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'select' #NEWLINE# choices = [ ] #NEWLINE# selected_ids = [ ] #NEWLINE# for ( value , label , selected ) in field . iter_choices ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# label = text_type ( label ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# label = '' #NEWLINE# #UNINDENT# choices . append ( { #NEWLINE# #INDENT# 'value' : text_type ( value ) , #NEWLINE# 'text' : label , #NEWLINE# #UNINDENT# } ) #NEWLINE# if separator : #NEWLINE# #INDENT# selected_ids . append ( value ) #NEWLINE# #UNINDENT# #UNINDENT# kwargs [ 'data-source' ] = json . dumps ( choices ) #NEWLINE# if ( field . type == 'QuerySelectMultipleField' ) : #NEWLINE# #INDENT# kwargs [ 'data-type' ] = 'select2' #NEWLINE# kwargs [ 'data-role' ] = 'x-editable-select2-multiple' #NEWLINE# separator = getattr ( field , 'separator' , ',' ) #NEWLINE# kwargs [ 'data-value' ] = separator . join ( selected_ids ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( ( 'Unsupported field type: %s' % ( type ( field ) , ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return kwargs