def add_container_page_publishing_info(xblock, xblock_info):
 def safe_get_username(user_id):
  '\n        Guard against bad user_ids, like the infamous "**replace_user**".\n        Note that this will ignore our special known IDs (ModuleStoreEnum.UserID).\n        We should consider adding special handling for those values.\n\n        :param user_id: the user id to get the username of\n        :return: username, or None if the user does not exist or user_id is None\n        '
  if user_id:
   try:
    return User.objects.get(id=user_id).username
   except:
    pass
  return None
 xblock_info['edited_by'] = safe_get_username(xblock.subtree_edited_by)
 xblock_info['published_by'] = safe_get_username(xblock.published_by)
 xblock_info['currently_visible_to_students'] = is_currently_visible_to_students(xblock)
 xblock_info['has_content_group_components'] = has_children_visible_to_specific_content_groups(xblock)
 if xblock_info['release_date']:
  xblock_info['release_date_from'] = _get_release_date_from(xblock)
 if (xblock_info['visibility_state'] == VisibilityState.staff_only):
  xblock_info['staff_lock_from'] = _get_staff_lock_from(xblock)
 else:
  xblock_info['staff_lock_from'] = None

def add_container_page_publishing_info ( xblock , xblock_info ) : def safe_get_username ( user_id ) : if user_id : try : return User . objects . get ( id = user_id ) . username except : pass return None xblock_info [ 'edited_by' ] = safe_get_username ( xblock . subtree_edited_by ) xblock_info [ 'published_by' ] = safe_get_username ( xblock . published_by ) xblock_info [ 'currently_visible_to_students' ] = is_currently_visible_to_students ( xblock ) xblock_info [ 'has_content_group_components' ] = has_children_visible_to_specific_content_groups ( xblock ) if xblock_info [ 'release_date' ] : xblock_info [ 'release_date_from' ] = _get_release_date_from ( xblock ) if ( xblock_info [ 'visibility_state' ] == VisibilityState . staff_only ) : xblock_info [ 'staff_lock_from' ] = _get_staff_lock_from ( xblock ) else : xblock_info [ 'staff_lock_from' ] = None
adds information about the xblocks publish state to the supplied xblock_info for the container page .