mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +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):
|
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)
|
return model_class.check_attachment_permission(permission, user)
|
||||||
|
@ -29,11 +29,14 @@ def attachment_model_options():
|
|||||||
|
|
||||||
def attachment_model_class_from_label(label: str):
|
def attachment_model_class_from_label(label: str):
|
||||||
"""Return the model class for the given label."""
|
"""Return the model class for the given label."""
|
||||||
|
if not label:
|
||||||
|
raise ValidationError(_('No attachment model type provided'))
|
||||||
|
|
||||||
for model in attachment_model_types():
|
for model in attachment_model_types():
|
||||||
if model.__name__.lower() == label.lower():
|
if model.__name__.lower() == label.lower():
|
||||||
return model
|
return model
|
||||||
|
|
||||||
raise ValueError(f'Invalid attachment model label: {label}')
|
raise ValidationError(_('Invalid attachment model type') + f": '{label}'")
|
||||||
|
|
||||||
|
|
||||||
def validate_attachment_model_type(value):
|
def validate_attachment_model_type(value):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user