mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-01 09:41:22 +00:00
Remove validator
This commit is contained in:
+1
-1
@@ -20,6 +20,6 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='notesimage',
|
model_name='notesimage',
|
||||||
name='model_type',
|
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),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ class Migration(migrations.Migration):
|
|||||||
models.ForeignKey(
|
models.ForeignKey(
|
||||||
on_delete=django.db.models.deletion.CASCADE,
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
to="contenttypes.contenttype",
|
to="contenttypes.contenttype",
|
||||||
validators=[common.validators.validate_notes_model_type]
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -2922,7 +2922,6 @@ class Parameter(
|
|||||||
if instance and isinstance(instance, InvenTreeParameterMixin):
|
if instance and isinstance(instance, InvenTreeParameterMixin):
|
||||||
instance.check_parameter_delete(self)
|
instance.check_parameter_delete(self)
|
||||||
|
|
||||||
# TODO: Reintroduce validator for model_type
|
|
||||||
model_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
model_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||||
|
|
||||||
model_id = models.PositiveIntegerField(
|
model_id = models.PositiveIntegerField(
|
||||||
@@ -3055,11 +3054,7 @@ class Note(
|
|||||||
if instance and isinstance(instance, InvenTreeNoteMixin):
|
if instance and isinstance(instance, InvenTreeNoteMixin):
|
||||||
instance.check_note_delete(self)
|
instance.check_note_delete(self)
|
||||||
|
|
||||||
model_type = models.ForeignKey(
|
model_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||||
ContentType,
|
|
||||||
on_delete=models.CASCADE,
|
|
||||||
validators=[common.validators.validate_notes_model_type],
|
|
||||||
)
|
|
||||||
|
|
||||||
model_id = models.PositiveIntegerField()
|
model_id = models.PositiveIntegerField()
|
||||||
|
|
||||||
@@ -3118,7 +3113,6 @@ class NotesImage(models.Model):
|
|||||||
max_length=100,
|
max_length=100,
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
validators=[common.validators.validate_notes_model_type],
|
|
||||||
help_text=_('Target model type for this image'),
|
help_text=_('Target model type for this image'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -109,28 +109,6 @@ def validate_attachment_file(attachment):
|
|||||||
raise ValidationError(_('Invalid file name'))
|
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):
|
def validate_decimal_places_min(value):
|
||||||
"""Validator for PRICING_DECIMAL_PLACES_MIN setting."""
|
"""Validator for PRICING_DECIMAL_PLACES_MIN setting."""
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user