2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

Clean up deprecated module removed in python 3.13 (#9004)

* Remove deprecated module removed in python 3.13

* Update validate to use helper function

* Add translation wrapper to error message
This commit is contained in:
Joe Rogers 2025-02-01 21:23:24 -05:00 committed by GitHub
parent 56bfbfb1b4
commit 1912e754b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,5 @@
"""DRF data serializers for Part app."""
import imghdr
import io
import os
from decimal import Decimal
@ -298,9 +297,9 @@ class PartThumbSerializerUpdate(InvenTree.serializers.InvenTreeModelSerializer):
def validate_image(self, value):
"""Check that file is an image."""
validate = imghdr.what(value)
validate = InvenTree.helpers.TestIfImage(value)
if not validate:
raise serializers.ValidationError('File is not an image')
raise serializers.ValidationError(_('File is not an image'))
return value
image = InvenTree.serializers.InvenTreeAttachmentSerializerField(required=True)