#NEWLINE# def _filter_metadata( metadata , **kwargs ) : #NEWLINE# #INDENT# 'Filter metadata before return it to api.\n\n    Some metadata fields are not json compatible or\n    only used in db/api internally.\n    We should strip these fields out before return to api.\n    ' #NEWLINE# if ( not isinstance ( metadata , dict ) ) : #NEWLINE# #INDENT# return metadata #NEWLINE# #UNINDENT# filtered_metadata = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( key , value ) in metadata . items ( ) : #NEWLINE# #INDENT# if ( key == '_self' ) : #NEWLINE# #INDENT# filtered_metadata [ key ] = { #NEWLINE# #INDENT# 'name' : value [ 'name' ] , #NEWLINE# 'description' : value . get ( 'description' , None ) , #NEWLINE# 'default_value' : value . get ( 'default_value' , None ) , #NEWLINE# 'is_required' : value . get ( 'is_required' , False ) , #NEWLINE# 'required_in_whole_config' : value . get ( 'required_in_whole_config' , False ) , #NEWLINE# 'js_validator' : value . get ( 'js_validator' , None ) , #NEWLINE# 'options' : value . get ( 'options' , None ) , #NEWLINE# 'required_in_options' : value . get ( 'required_in_options' , False ) , #NEWLINE# 'field_type' : value . get ( 'field_type_data' , 'str' ) , #NEWLINE# 'display_type' : value . get ( 'display_type' , None ) , #NEWLINE# 'mapping_to' : value . get ( 'mapping_to' , None ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# filtered_metadata [ key ] = _filter_metadata ( value , ** filtered_metadata ) #NEWLINE# #UNINDENT# #UNINDENT# return filtered_metadata