Self hosted FLOSS fitness/workout, nutrition and weight tracker
Also save ingredient image width and height
Roland Geider4772693ece9e
diff --git a/wger/nutrition/api/serializers.py b/wger/nutrition/api/serializers.pyindex 1be023ecd..32260f802 100644--- a/wger/nutrition/api/serializers.py+++ b/wger/nutrition/api/serializers.py@@ -93,6 +93,8 @@ class ImageSerializer(serializers.ModelSerializer):'created','last_update','size',+ 'width',+ 'height','license','license_title','license_object_url',diff --git a/wger/nutrition/migrations/0013_ingredient_image.py b/wger/nutrition/migrations/0013_ingredient_image.pyindex b78c64a59..14aa79ab2 100644--- a/wger/nutrition/migrations/0013_ingredient_image.py+++ b/wger/nutrition/migrations/0013_ingredient_image.py@@ -78,11 +78,15 @@ class Migration(migrations.Migration):help_text='Only PNG and JPEG formats are supported',upload_to=wger.nutrition.models.image.ingredient_image_upload_dir,verbose_name='Image',+ height_field='height',+ width_field='width',)),('created', models.DateTimeField(auto_now_add=True)),('last_update', models.DateTimeField(auto_now=True)),('size', models.IntegerField()),+ ('height', models.IntegerField(editable=False)),+ ('width', models.IntegerField(editable=False)),('ingredient',models.OneToOneField(diff --git a/wger/nutrition/models/image.py b/wger/nutrition/models/image.pyindex 2d8618416..6ee39631e 100644--- a/wger/nutrition/models/image.py+++ b/wger/nutrition/models/image.py@@ -60,6 +60,8 @@ class Image(AbstractLicenseModel, models.Model, BaseImage):verbose_name=_('Image'),help_text=_('Only PNG and JPEG formats are supported'),upload_to=ingredient_image_upload_dir,+ height_field='height',+ width_field='width',)"""Uploaded image"""@@ -72,6 +74,12 @@ class Image(AbstractLicenseModel, models.Model, BaseImage):size = models.IntegerField()"""The size of the image in bytes"""+ height = models.IntegerField(editable=False)+ """Height of the image"""++ width = models.IntegerField(editable=False)+ """Width of the image"""+@classmethoddef from_json(cls,diff --git a/wger/nutrition/tests/test_tasks.py b/wger/nutrition/tests/test_tasks.pyindex cf6709b79..792e38dfd 100644--- a/wger/nutrition/tests/test_tasks.py+++ b/wger/nutrition/tests/test_tasks.py@@ -80,6 +80,8 @@ class MockWgerApiResponse:"created": "2023-03-15T23:20:10.969369+01:00","last_update": "2023-03-15T23:20:10.969369+01:00","size": 20179,+ "width": 400,+ "height": 166,"license": 1,"license_author": "Tester McTest","license_author_url": "https://example.com/editors/mcLovin",