Ejemplo n.º 1
0
    def validate_child_concepts(cls, obj):
        # If source is being configured to have a validation schema
        # we need to validate all concepts
        # according to the new schema
        from concepts.models import Concept
        from concepts.validators import ValidatorSpecifier

        concepts = Concept.objects.filter(parent_id=obj.id, is_active=True, retired=False).all()
        failed_concept_validations = []

        validator = ValidatorSpecifier()\
            .with_validation_schema(obj.custom_validation_schema)\
            .with_repo(obj)\
            .with_reference_values()\
            .get()

        for concept in concepts:
            try:
                validator.validate(concept)
                pass
            except ValidationError as validation_error:
                concept_validation_error = {'mnemonic': concept.mnemonic, 'url': concept.url, 'errors': validation_error.message_dict}
                failed_concept_validations.append(concept_validation_error)

        return failed_concept_validations
Ejemplo n.º 2
0
    def validate_child_concepts(cls, obj):
        # If source is being configured to have a validation schema
        # we need to validate all concepts
        # according to the new schema
        from concepts.models import Concept
        from concepts.validators import ValidatorSpecifier

        concepts = Concept.objects.filter(parent_id=obj.id, is_active=True, retired=False).all()
        failed_concept_validations = []

        validator = ValidatorSpecifier()\
            .with_validation_schema(obj.custom_validation_schema)\
            .with_repo(obj)\
            .with_reference_values()\
            .get()

        for concept in concepts:
            try:
                validator.validate(concept)
                pass
            except ValidationError as validation_error:
                concept_validation_error = {'mnemonic': concept.mnemonic, 'url': concept.url, 'errors': validation_error.message_dict}
                failed_concept_validations.append(concept_validation_error)

        return failed_concept_validations
Ejemplo n.º 3
0
    def clean(self):
        if os.environ.get('DISABLE_VALIDATION'):
            return

        validators = [BasicConceptValidator()]

        schema = self.parent_source.custom_validation_schema
        if schema:
            custom_validator = ValidatorSpecifier()\
                .with_validation_schema(schema)\
                .with_repo(self.parent_source)\
                .with_reference_values()\
                .get()
            validators.append(custom_validator)

        for validator in validators:
            validator.validate(self)
Ejemplo n.º 4
0
    def clean(self):
        from concepts.models import Concept

        if os.environ.get('DISABLE_VALIDATION'):
            return

        validators = [BasicConceptValidator()]
        other_concepts = list(
            Concept.objects.filter(parent_id=self.parent_source.id,
                                   is_active=True,
                                   retired=False).values_list('id', flat=True))

        schema = self.parent_source.custom_validation_schema
        if schema:
            custom_validator = ValidatorSpecifier()\
                .with_validation_schema(schema)\
                .with_repo(self.parent_source)\
                .with_reference_values()\
                .get()
            validators.append(custom_validator)

        for validator in validators:
            validator.validate(self)