'Defines a hook to process list view data before being serialized.
We pluck out the "user" and replace with the fields we\'re interested in (username, facility name, is_teacher),
and pluck out the content_id and replace with the content_title (if found).
This is to make the csv output more human friendly.
:param request: HTTP request object
:param to_be_serialized: the unprocessed list of objects that will be serialized
:return: the _processed_ list of objects to serialize'

def alter_list_data_to_serialize(self, request, to_be_serialized):

    filtered_bundles = [bundle for bundle in to_be_serialized['objects'] if ((bundle.data['difficulty'], bundle.data['quality']) != (0, 0))]
    serializable_objects = []
    for bundle in filtered_bundles:
        user_id = bundle.data['user'].data['id']
        user = self._facility_users.get(user_id)
        bundle.data['username'] = user.username
        bundle.data['facility_name'] = user.facility.name
        bundle.data['is_teacher'] = user.is_teacher
        bundle.data.pop('user')
        content_id = bundle.data.pop('content_id', None)
        content = get_content_item(language=request.language, content_id=content_id)
        bundle.data['content_title'] = (content.get('title', 'Missing    title') if content else 'Unknown    content')
        serializable_objects.append(bundle)
    to_be_serialized['objects'] = serializable_objects
    return to_be_serialized
