def get_object_users_with_permissions(obj, exclude=None, serializable=False):
    result = []

    if obj:
        users_with_perms = get_users_with_perms(
            obj, attach_perms=True, with_group_users=False).items()

        result = [{
            'user': user if not serializable else user.username,
            'role': get_role(permissions, obj),
            'permissions': permissions} for user, permissions in
            users_with_perms if not is_organization(
                UserProfile.objects.get_or_create(user=user)[0]
            )
        ]

    return result
Returns users, roles and permissions for a object.
dataset/ETHPy150Open kobotoolbox/kobocat/onadata/libs/permissions.py/get_object_users_with_permissions