def get_location(metadata):
    """Get location from ip context metadata."""
    city = metadata['city']
    country = metadata['country']
    country_code = metadata['country_code']
    location = []
    if city:
        location.append('{},'.format(city))
    if country:
        location.append(country)
    if country_code:
        location.append('({})'.format(country_code))
    return ' '.join(location)
