def get_contact_objects(current_user, contact):
 objects = dict(CONTACT_OBJECTS)
 for key in objects:
  if hasattr(contact, key):
   manager = getattr(contact, key)
   try:
    manager = manager.filter(status__hidden=False)
   except:
    pass
   objects[key]['objects'] = Object.filter_permitted(current_user, manager)
 return objects

def get_contact_objects ( current_user , contact ) : objects = dict ( CONTACT_OBJECTS ) for key in objects : if hasattr ( contact , key ) : manager = getattr ( contact , key ) try : manager = manager . filter ( status__hidden = False ) except : pass objects [ key ] [ 'objects' ] = Object . filter_permitted ( current_user , manager ) return objects
returns a dictionary with keys specified as contact attributes and values as dictionaries with labels and set of relevant objects .