Exemplo n.º 1
0
    def clean_name(self):
        name = slugify(self.cleaned_data["name"])
        name = name.lower()

        if not (self.instance and self.instance.name == name ):
            if Application.objects.filter(name=name, project=self.project):
               raise ValidationError('%s is already in use in this project' % name)
        return name
Exemplo n.º 2
0
    def clean_name(self):
        name = slugify(self.cleaned_data["name"])
        name = name.lower()

        if not (self.instance and self.instance.name == name):
            if Application.objects.filter(name=name, project=self.project):
                raise ValidationError('%s is already in use in this project' %
                                      name)
        return name
Exemplo n.º 3
0
    def clean_name(self):
        name = self.cleaned_data["name"]
        name = slugify(name).lower()

        if not (self.instance and self.instance.name == name ):
            for model_field in ModelField.objects.filter(model=self.model).select_related():
                # first test ensure name has been changed. 
                # So it should not exist on any other object in this model.
                if model_field.object.name == name:
                    raise ValidationError('%s is already in use in this model' % name)
        return name
Exemplo n.º 4
0
    def clean_name(self):
        """
        ensure that a name get cast to CamelCase
        "my model name" should become "MyModelName"
        """
        name = self.cleaned_data["name"]
        name = ''.join([ '%s%s' % (x[0].upper(),x[1:]) for x in name.split(' ') if x ])
        name = slugify(name)

        if not (self.instance and self.instance.name == name ):
            if Model.objects.filter(name=name, application=self.application):
               raise ValidationError('%s is already in use in this application' % name)

        return name