## Script (Python) "ts_roster_get_display_fields"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=display_fields=None,vis_key='roster_list'
##title=Get Schema Fields to Display on Team Roster

try:
    md_tool = context.portal_memberdata
    at_tool = context.archetype_tool
    mem_type = md_tool.getTypeName()
    schema = md_tool.getMemberSchema(schema_id=mem_type)

    if not display_fields:
        isRosterListField = lambda field: at_tool.visibleLookup(field, vis_key)
        results = schema.filterFields(isRosterListField)

        if not results:
            display_fields = ('fullname', 'id', 'email', )
            results = [schema[fn] for fn in display_fields]
except AttributeError:
    return ()

return results
