Remove validator

This commit is contained in:
Oliver Walters 2026-05-25 11:58:16 +00:00
parent 24e8faddca
commit c2e18932db
4 changed files with 2 additions and 31 deletions

View File

@ -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),
),
]

View File

@ -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]
),
),
(

View File

@ -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'),
)

View File

@ -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: