

def clean(self):
    map(validate_site_name, self.full_name.split('.'))
    (self.name, parent_name) = (self.full_name.split('.')[0], self.full_name.split('.')[1:])
    validate_site_name(self.name)
    if self.pk:
        db_self = self.__class__.objects.get(pk=self.pk)
        if (self.site_set.exists() and (self.name != db_self.name)):
            raise ValidationError("This site has child sites. You cannot change it's name without affecting all child sites.")
    if (not (self.full_name.find('.') == (- 1))):
        (self.parent, _) = self.__class__.objects.get_or_create(full_name='.'.join(parent_name))
    else:
        self.parent = None

dataset/ETHPy150Open mozilla/inventory/core/site/models.py Site.clean/original