mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Error checking for attachment model type (#7506)
This commit is contained in:
parent
c6ad902ccc
commit
4989e86349
@ -3241,6 +3241,6 @@ class Attachment(InvenTree.models.MetadataMixin, InvenTree.models.InvenTreeModel
|
||||
)
|
||||
|
||||
if not issubclass(model_class, InvenTreeAttachmentMixin):
|
||||
raise ValueError(_('Invalid model type specified for attachment'))
|
||||
raise ValidationError(_('Invalid model type specified for attachment'))
|
||||
|
||||
return model_class.check_attachment_permission(permission, user)
|
||||
|
@ -29,11 +29,14 @@ def attachment_model_options():
|
||||
|
||||
def attachment_model_class_from_label(label: str):
|
||||
"""Return the model class for the given label."""
|
||||
if not label:
|
||||
raise ValidationError(_('No attachment model type provided'))
|
||||
|
||||
for model in attachment_model_types():
|
||||
if model.__name__.lower() == label.lower():
|
||||
return model
|
||||
|
||||
raise ValueError(f'Invalid attachment model label: {label}')
|
||||
raise ValidationError(_('Invalid attachment model type') + f": '{label}'")
|
||||
|
||||
|
||||
def validate_attachment_model_type(value):
|
||||
|
Loading…
Reference in New Issue
Block a user