def mask_results(search_results):
    """masks (deletes dict keys) for non-shared public fields"""
    whitelist_fields = {}
    results = []
    for b in search_results:
        parent_org = Organization.objects.get(pk=b['super_organization'])
        parent_org = parent_org.get_parent()
        if parent_org.id not in whitelist_fields:
            whitelist_fields[parent_org.id] = []
            for s in parent_org.sharedbuildingfield_set.filter(
                field_type=PUBLIC
            ):
                whitelist_fields[parent_org.id].append(s.field.name)

        d = {}
        for key in b:
            if key in whitelist_fields[parent_org.id]:
                d[key] = b[key]
        results.append(d)
    return results
dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/search.py/mask_results/original