Esempio n. 1
0
    def clean(self, ignore_conflicts=False):
        if self.name.endswith('arpa'):
            self.is_reverse = True
        self.master_domain = name_to_master_domain(self.name)

        if not self.master_domain and self.name in ('reverse', 'config'):
            # Right now zone files get placed into invzones/ where directories
            # corresponding to TLDs are placed. There are also directories
            # invzones/config/ (where configs are stored) and invzones/reverse/
            # (where reverse zones are stored) -- we don't want to clobber
            # these directories with TLD directories.
            raise ValidationError(
                "{0} is a reserved TLD name".format(self.name)
            )

        do_zone_validation(self)
        # TODO, can we remove this?
        if self.pk is None and not ignore_conflicts:
            # The object doesn't exist in the db yet. Make sure we don't
            # conflict with existing objects. We may want to move to a more
            # automatic solution where the creation of a new domain will
            # automatically move objects around (see the ensure_domain
            # function).
            qset = smart_fqdn_exists(self.name)
            if qset:
                objects = qset.all()
                raise ValidationError("Objects with this name already "
                                      "exist {0}".format(objects))
        elif self.pk is not None:
            db_self = Domain.objects.get(pk=self.pk)
            if db_self.name != self.name and self.domain_set.exists():
                raise ValidationError("Child domains rely on this domain's "
                                      "name remaining the same.")
    def clean(self, ignore_conflicts=False):
        if self.name.endswith('arpa'):
            self.is_reverse = True
        self.master_domain = name_to_master_domain(self.name)

        if not self.master_domain and self.name in ('reverse', 'config'):
            # Right now zone files get placed into invzones/ where directories
            # corresponding to TLDs are placed. There are also directories
            # invzones/config/ (where configs are stored) and invzones/reverse/
            # (where reverse zones are stored) -- we don't want to clobber
            # these directories with TLD directories.
            raise ValidationError("{0} is a reserved TLD name".format(
                self.name))

        do_zone_validation(self)
        # TODO, can we remove this?
        if self.pk is None and not ignore_conflicts:
            # The object doesn't exist in the db yet. Make sure we don't
            # conflict with existing objects. We may want to move to a more
            # automatic solution where the creation of a new domain will
            # automatically move objects around (see the ensure_domain
            # function).
            qset = smart_fqdn_exists(self.name)
            if qset:
                objects = qset.all()
                raise ValidationError("Objects with this name already "
                                      "exist {0}".format(objects))
        elif self.pk is not None:
            db_self = Domain.objects.get(pk=self.pk)
            if db_self.name != self.name and self.domain_set.exists():
                raise ValidationError("Child domains rely on this domain's "
                                      "name remaining the same.")
    def clean(self):
        if self.name.endswith('arpa'):
            self.is_reverse = True
        self.master_domain = name_to_master_domain(self.name)

        do_zone_validation(self)
        # TODO, can we remove this?
        if self.pk is None:
            # The object doesn't exist in the db yet. Make sure we don't
            # conflict with existing objects. We may want to move to a more
            # automatic solution where the creation of a new domain will
            # automatically move objects around (see the ensure_domain
            # function).
            qset = smart_fqdn_exists(self.name)
            if qset:
                objects = qset.all()
                raise ValidationError("Objects with this name already "
                                      "exist {0}".format(objects))
        else:
            db_self = Domain.objects.get(pk=self.pk)
            if db_self.name != self.name and self.domain_set.exists():
                raise ValidationError("Child domains rely on this domain's "
                                      "name remaining the same.")