Example #1
0
 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)
Example #2
0
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
Example #3
0
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
Example #4
0
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
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 def country_code(self):
     iso2 = Country.name_from_id(int(self.region.country)).upper()
     return iso2_to_iso3(iso2)
Example #8
0
 def country_code(self):
     iso2 = Country.name_from_id(self.owner.profile.country).upper()
     return iso2_to_iso3.get(iso2, 'POL')
Example #9
0
 def country_code(self):
     iso2 = Country.name_from_id(self.owner.profile.country).upper()
     return iso2_to_iso3.get(iso2, 'POL')