<s> from sqlalchemy import inspect <EOL> class ModelAdmin ( object ) : <EOL> """<STR_LIT>""" <EOL> list_display = tuple ( ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . name ) <EOL> def __init__ ( self , model , site ) : <EOL> from . sites import site <EOL> self . model_cls = model <EOL> self . site = site <EOL> self . name = self . model_cls . __name__ . lower ( ) <EOL> self . add_url = '<STR_LIT>' . format ( site . url_prefix , self . name ) <EOL> self . list_url = '<STR_LIT>' . format ( site . url_prefix , self . name ) <EOL> self . edit_url = '<STR_LIT>' . format ( site . url_prefix , self . name ) <EOL> self . delete_url = '<STR_LIT>' . format ( site . url_prefix , self . name ) <EOL> @ property <EOL> def columns ( self ) : <EOL> mapper = inspect ( self . model_cls ) <EOL> attrs = [ prop . columns [ <NUM_LIT:0> ] for prop in mapper . attrs ] <EOL> return ( prop . name for prop in attrs if prop . name != '<STR_LIT:id>' ) <EOL> def get_list_display ( self ) : <EOL> return self . list_display <EOL> def get_select_fields ( self ) : <EOL> list_display = self . get_list_display ( ) <EOL> fields = [ ] <EOL> for field in list_display : <EOL> attr = getattr ( self . model_cls , field ) <EOL> try : <EOL> attr = attr ( ) <EOL> except : <EOL> pass <EOL> fields . append ( attr ) <EOL> return fields </s>
