def change_hostname(cls, instances, **kwargs): country_id = kwargs['country'] country_name = Country.name_from_id(int(country_id)).upper() iso3_country_name = iso2_to_iso3(country_name) for instance in instances: instance._try_assign_hostname(country=iso3_country_name, force=True)
def get_user_iso3_country_name(user): """ :param user: instance of django.contrib.auth.models.User which has profile with country attribute """ country_name = Country.name_from_id(int(user.country)) iso3_country_name = iso2_to_iso3(country_name) return iso3_country_name
def country_code(self): iso2 = Country.name_from_id(int(self.region.country)).upper() return iso2_to_iso3(iso2)
def test_convert_iso2_to_iso3(self): self.assertEqual(iso2_to_iso3('PL'), 'POL')