def is_allowed_country(country_object, context=None):
 if (context and context.get('allowed_countries')):
  allowed_countries = context.get('allowed_countries')
  return ((country_object.name.lower() in allowed_countries) or (country_object.alpha2.lower() in allowed_countries))
 return True

def is_allowed_country ( country_object , context = None ) : if ( context and context . get ( 'allowed_countries' ) ) : allowed_countries = context . get ( 'allowed_countries' ) return ( ( country_object . name . lower ( ) in allowed_countries ) or ( country_object . alpha2 . lower ( ) in allowed_countries ) ) return True
check if country is allowed .