def _get_user_display_name(user):
    """Return a human-friendly display name for a user."""
    # An anonymous user has no display name
    if user.is_anonymous:
        return ''

    # Form display name by concatenating first and last names and stripping whitespace
    display_name = user.get_full_name().strip()

    # If the display name is empty, use the username instead
    if display_name == '':
        return user.username

    return display_name