<s> from wtforms import widgets <EOL> from flask . globals import _request_ctx_stack <EOL> from flask_admin . babel import gettext , ngettext <EOL> from flask_admin import helpers as h <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ] <EOL> def _is_bootstrap3 ( ) : <EOL> view = h . get_current_view ( ) <EOL> return view and view . admin . template_mode == '<STR_LIT>' <EOL> class Select2Widget ( widgets . Select ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self , field , ** kwargs ) : <EOL> kwargs . setdefault ( '<STR_LIT>' , u'<STR_LIT>' ) <EOL> allow_blank = getattr ( field , '<STR_LIT>' , False ) <EOL> if allow_blank and not self . multiple : <EOL> kwargs [ '<STR_LIT>' ] = u'<STR_LIT:1>' <EOL> return super ( Select2Widget , self ) . __call__ ( field , ** kwargs ) <EOL> class Select2TagsWidget ( widgets . TextInput ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self , field , ** kwargs ) : <EOL> kwargs . setdefault ( '<STR_LIT>' , u'<STR_LIT>' ) <EOL> kwargs . setdefault ( '<STR_LIT>' , u'<STR_LIT:1>' ) <EOL> return super ( Select2TagsWidget , self ) . __call__ ( field , ** kwargs ) <EOL> class DatePickerWidget ( widgets . TextInput ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self , field , ** kwargs ) : <EOL> kwargs . setdefault ( '<STR_LIT>' , u'<STR_LIT>' ) <EOL> kwargs . setdefault ( '<STR_LIT>' , u'<STR_LIT>' ) <EOL> self . date_format = kwargs [ '<STR_LIT>' ] <EOL> return super ( DatePickerWidget , self ) . __call__ ( field , ** kwargs ) <EOL> class DateTimePickerWidget ( widgets . TextInput ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self , field , ** kwargs ) : <EOL> kwargs . setdefault ( '<STR_LIT>' , u'<STR_LIT>' ) <EOL> kwargs . setdefault ( '<STR_LIT>' , u'<STR_LIT>' ) <EOL> return super ( DateTimePickerWidget , self ) . __call__ ( field , ** kwargs ) <EOL> class TimePickerWidget ( widgets . TextInput ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self , field , ** kwargs ) : <EOL> kwargs . setdefault ( '<STR_LIT>' , u'<STR_LIT>' ) <EOL> kwargs . setdefault ( '<STR_LIT>' , u'<STR_LIT>' ) <EOL> return super ( TimePickerWidget , self ) . __call__ ( field , ** kwargs ) <EOL> class RenderTemplateWidget ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , template ) : <EOL> """<STR_LIT>""" <EOL> self . template = template <EOL> def __call__ ( self , field , ** kwargs ) : <EOL> ctx = _request_ctx_stack . top <EOL> jinja_env = ctx . app . jinja_env <EOL> kwargs . update ( { <EOL> '<STR_LIT>' : field , <EOL> '<STR_LIT>' : gettext , <EOL> '<STR_LIT>' : ngettext , <EOL> '<STR_LIT:h>' : h , <EOL> } ) <EOL> template = jinja_env . get_template ( self . template ) <EOL> return template . render ( kwargs ) </s>
