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 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(user.get_profile().country).upper() iso3_country_name = iso2_to_iso3[country_name] return iso3_country_name
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(user.get_profile().country).upper() iso3_country_name = iso2_to_iso3[country_name] return iso3_country_name
def _action_change_hostname(self): for asset in self.assets: country_id = self.kwargs['request'].POST.get('country') country_name = Country.name_from_id(int(country_id)).upper() iso3_country_name = iso2_to_iso3[country_name] template_vars = { 'code': asset.model.category.code, 'country_code': iso3_country_name, } asset.generate_hostname(template_vars=template_vars) asset.save(user=self.logged_user)
def _action_change_hostname(self): for asset in self.assets: country_id = self.kwargs['request'].POST.get('country') country_name = Country.name_from_id(int(country_id)).upper() iso3_country_name = iso2_to_iso3[country_name] template_vars = { 'code': asset.model.category.code, 'country_code': iso3_country_name, } asset.generate_hostname(template_vars=template_vars) asset.save(user=self.logged_user)
def country_code(self): iso2 = Country.name_from_id(int(self.region.country)).upper() return iso2_to_iso3(iso2)
def country_code(self): iso2 = Country.name_from_id(self.owner.profile.country).upper() return iso2_to_iso3.get(iso2, 'POL')
def country_code(self): iso2 = Country.name_from_id(self.owner.profile.country).upper() return iso2_to_iso3.get(iso2, 'POL')