<s> from flask import request , url_for <EOL> from flask . ext . admin import BaseView , expose <EOL> from flask . ext . admin . _backwards import ObsoleteAttr <EOL> from jinja2 import contextfunction <EOL> class BaseModelView ( BaseView ) : <EOL> column_sortable_list = ObsoleteAttr ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> None ) <EOL> column_descriptions = None <EOL> def _get_url ( self , view = None , page = None , sort = None , sort_desc = None , <EOL> search = None ) : <EOL> if not search : <EOL> search = None <EOL> if not page : <EOL> page = None <EOL> kwargs = dict ( page = page , sort = sort , desc = sort_desc , search = search ) <EOL> return url_for ( view , ** kwargs ) <EOL> def _get_list_extra_args ( self ) : <EOL> """<STR_LIT>""" <EOL> page = request . args . get ( '<STR_LIT>' , <NUM_LIT:0> , type = int ) <EOL> sort = request . args . get ( '<STR_LIT>' , None , type = int ) <EOL> sort_desc = request . args . get ( '<STR_LIT>' , None , type = int ) <EOL> search = request . args . get ( '<STR_LIT>' , None ) <EOL> return page , sort , sort_desc , search <EOL> @ expose ( '<STR_LIT>' , methods = ( '<STR_LIT:POST>' , ) ) <EOL> def action_view ( self ) : <EOL> return self . handle_action ( ) <EOL> def is_sortable ( self , name ) : <EOL> return name in self . get_sortable_columns ( ) <EOL> def get_sortable_columns ( self ) : <EOL> if self . column_sortable_list is None : <EOL> return dict ( ) <EOL> else : <EOL> result = dict ( ) <EOL> for c in self . column_sortable_list : <EOL> if isinstance ( c , tuple ) : <EOL> result [ c [ <NUM_LIT:0> ] ] = c [ <NUM_LIT:1> ] <EOL> else : <EOL> result [ c ] = c <EOL> return result <EOL> @ contextfunction <EOL> def get_list_value ( self , context , model , name ) : <EOL> return model [ name ] </s>
