def add_courseware_context(content_list, course, user, id_map=None):
 if (id_map is None):
  id_map = get_cached_discussion_id_map(course, [content['commentable_id'] for content in content_list], user)
 for content in content_list:
  commentable_id = content['commentable_id']
  if (commentable_id in id_map):
   location = id_map[commentable_id]['location'].to_deprecated_string()
   title = id_map[commentable_id]['title']
   url = reverse('jump_to', kwargs={'course_id': course.id.to_deprecated_string(), 'location': location})
   content.update({'courseware_url': url, 'courseware_title': title})

def add_courseware_context ( content_list , course , user , id_map = None ) : if ( id_map is None ) : id_map = get_cached_discussion_id_map ( course , [ content [ 'commentable_id' ] for content in content_list ] , user ) for content in content_list : commentable_id = content [ 'commentable_id' ] if ( commentable_id in id_map ) : location = id_map [ commentable_id ] [ 'location' ] . to_deprecated_string ( ) title = id_map [ commentable_id ] [ 'title' ] url = reverse ( 'jump_to' , kwargs = { 'course_id' : course . id . to_deprecated_string ( ) , 'location' : location } ) content . update ( { 'courseware_url' : url , 'courseware_title' : title } )
decorates content_list with courseware metadata using the discussion id map cache if available .