#NEWLINE# def columns_for_model( model , fields = None , exclude = None , labels = None , processors = None , unsortable = None , hidden = None ) : #NEWLINE# #INDENT# field_list = [ ] #NEWLINE# opts = model . _meta #NEWLINE# for f in sorted ( opts . fields ) : #NEWLINE# #INDENT# if ( ( fields is not None ) and ( f . name not in fields ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( opts and ( f . name in exclude ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# column_class = get_column_for_modelfield ( f ) #NEWLINE# if ( column_class is None ) : #NEWLINE# #INDENT# raise ColumnError ( ( 'Unhandled model field %r.' % ( f , ) ) ) #NEWLINE# #UNINDENT# if ( labels and ( f . name in labels ) ) : #NEWLINE# #INDENT# label = labels [ f . name ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# label = f . verbose_name #NEWLINE# #UNINDENT# if ( processors and ( f . name in processors ) ) : #NEWLINE# #INDENT# processor = processors [ f . name ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# processor = None #NEWLINE# #UNINDENT# if ( unsortable and ( f . name in unsortable ) ) : #NEWLINE# #INDENT# sortable = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sortable = True #NEWLINE# #UNINDENT# if ( hidden and ( f . name in hidden ) ) : #NEWLINE# #INDENT# visible = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# visible = True #NEWLINE# #UNINDENT# label = ( labels or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( f . name , pretty_name ( f . verbose_name ) ) #NEWLINE# column = column_class ( sources = [ f . name ] , label = label , processor = processor , sortable = sortable , visible = visible ) #NEWLINE# column . name = f . name #NEWLINE# field_list . append ( ( f . name , column ) ) #NEWLINE# #UNINDENT# field_dict = OrderedDict ( field_list ) #NEWLINE# if fields : #NEWLINE# #INDENT# field_dict = OrderedDict ( [ ( f , field_dict . get ( f ) ) for f in fields if ( ( not exclude ) or ( exclude and ( f not in exclude ) ) ) ] ) #NEWLINE# #UNINDENT# return field_dict