mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +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:
		| @@ -1,6 +1,5 @@ | |||||||
| """DRF data serializers for Part app.""" | """DRF data serializers for Part app.""" | ||||||
|  |  | ||||||
| import imghdr |  | ||||||
| import io | import io | ||||||
| import os | import os | ||||||
| from decimal import Decimal | from decimal import Decimal | ||||||
| @@ -298,9 +297,9 @@ class PartThumbSerializerUpdate(InvenTree.serializers.InvenTreeModelSerializer): | |||||||
|  |  | ||||||
|     def validate_image(self, value): |     def validate_image(self, value): | ||||||
|         """Check that file is an image.""" |         """Check that file is an image.""" | ||||||
|         validate = imghdr.what(value) |         validate = InvenTree.helpers.TestIfImage(value) | ||||||
|         if not validate: |         if not validate: | ||||||
|             raise serializers.ValidationError('File is not an image') |             raise serializers.ValidationError(_('File is not an image')) | ||||||
|         return value |         return value | ||||||
|  |  | ||||||
|     image = InvenTree.serializers.InvenTreeAttachmentSerializerField(required=True) |     image = InvenTree.serializers.InvenTreeAttachmentSerializerField(required=True) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user