diff --git a/src/backend/InvenTree/common/migrations/0024_notesimage_model_id_notesimage_model_type.py b/src/backend/InvenTree/common/migrations/0024_notesimage_model_id_notesimage_model_type.py index 24467f9ba2..681cd2633a 100644 --- a/src/backend/InvenTree/common/migrations/0024_notesimage_model_id_notesimage_model_type.py +++ b/src/backend/InvenTree/common/migrations/0024_notesimage_model_id_notesimage_model_type.py @@ -20,6 +20,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='notesimage', name='model_type', - field=models.CharField(blank=True, null=True, help_text='Target model type for this image', max_length=100, validators=[common.validators.validate_notes_model_type]), + field=models.CharField(blank=True, null=True, help_text='Target model type for this image', max_length=100), ), ] diff --git a/src/backend/InvenTree/common/migrations/0044_note.py b/src/backend/InvenTree/common/migrations/0044_note.py index f6338bc6b0..afbb179eba 100644 --- a/src/backend/InvenTree/common/migrations/0044_note.py +++ b/src/backend/InvenTree/common/migrations/0044_note.py @@ -74,7 +74,6 @@ class Migration(migrations.Migration): models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, to="contenttypes.contenttype", - validators=[common.validators.validate_notes_model_type] ), ), ( diff --git a/src/backend/InvenTree/common/models.py b/src/backend/InvenTree/common/models.py index 37fbda2752..29738961f5 100644 --- a/src/backend/InvenTree/common/models.py +++ b/src/backend/InvenTree/common/models.py @@ -2922,7 +2922,6 @@ class Parameter( if instance and isinstance(instance, InvenTreeParameterMixin): instance.check_parameter_delete(self) - # TODO: Reintroduce validator for model_type model_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) model_id = models.PositiveIntegerField( @@ -3055,11 +3054,7 @@ class Note( if instance and isinstance(instance, InvenTreeNoteMixin): instance.check_note_delete(self) - model_type = models.ForeignKey( - ContentType, - on_delete=models.CASCADE, - validators=[common.validators.validate_notes_model_type], - ) + model_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) model_id = models.PositiveIntegerField() @@ -3118,7 +3113,6 @@ class NotesImage(models.Model): max_length=100, blank=True, null=True, - validators=[common.validators.validate_notes_model_type], help_text=_('Target model type for this image'), ) diff --git a/src/backend/InvenTree/common/validators.py b/src/backend/InvenTree/common/validators.py index 1aec813e64..c53a85ee5c 100644 --- a/src/backend/InvenTree/common/validators.py +++ b/src/backend/InvenTree/common/validators.py @@ -109,28 +109,6 @@ def validate_attachment_file(attachment): raise ValidationError(_('Invalid file name')) -def validate_notes_model_type(value): - """Ensure that the provided model type is valid. - - The provided value must map to a model which implements the 'InvenTreeNoteMixin'. - """ - import InvenTree.helpers_model - import InvenTree.models - - if not value: - # Empty values are allowed - return - - model_types = list( - InvenTree.helpers_model.getModelsWithMixin(InvenTree.models.InvenTreeNoteMixin) - ) - - model_names = [model.__name__.lower() for model in model_types] - - if value.lower() not in model_names: - raise ValidationError(f"Invalid model type '{value}'") - - def validate_decimal_places_min(value): """Validator for PRICING_DECIMAL_PLACES_MIN setting.""" try: