Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Allow to correctly filter by exercise UUID

Roland Geiderb51002d7a518
diff --git a/wger/nutrition/api/serializers.py b/wger/nutrition/api/serializers.py
index b90adaad2..38984f85d 100644
--- a/wger/nutrition/api/serializers.py
+++ b/wger/nutrition/api/serializers.py
@@ -82,7 +82,7 @@ class ImageSerializer(serializers.ModelSerializer):
"""
ingredient_uuid = serializers.CharField(source='ingredient.uuid', read_only=True)
- ingredient_id = serializers.CharField(source='ingredient.id', read_only=True)
+ ingredient_id = serializers.PrimaryKeyRelatedField(read_only=True)
class Meta:
model = Image
@@ -265,7 +265,7 @@ class NutritionPlanSerializer(serializers.ModelSerializer):
class Meta:
model = NutritionPlan
- exclude = ('user', )
+ exclude = ('user',)
class NutritionPlanInfoSerializer(serializers.ModelSerializer):
diff --git a/wger/nutrition/api/views.py b/wger/nutrition/api/views.py
index 6507bda37..68717b7eb 100644
--- a/wger/nutrition/api/views.py
+++ b/wger/nutrition/api/views.py
@@ -209,9 +209,9 @@ class ImageViewSet(viewsets.ReadOnlyModelViewSet):
ordering_fields = '__all__'
filterset_fields = (
'uuid',
- 'ingredient_uuid',
'source_url',
- 'ingredient_id'
+ 'ingredient_id',
+ 'ingredient__uuid'
)
@method_decorator(cache_page(settings.WGER_SETTINGS['EXERCISE_CACHE_TTL']))
diff --git a/wger/nutrition/sync.py b/wger/nutrition/sync.py
index 9a0111c3b..2b852a18e 100644
--- a/wger/nutrition/sync.py
+++ b/wger/nutrition/sync.py
@@ -68,7 +68,7 @@ def fetch_ingredient_image(pk: int):
def fetch_image_from_wger_instance(ingredient):
- url = make_uri(IMAGE_ENDPOINT, query={'uuid': ingredient.uuid})
+ url = make_uri(IMAGE_ENDPOINT, query={'ingredient__uuid': ingredient.uuid})
logger.info(f'Trying to fetch image from WGER for {ingredient.name} (UUID: {ingredient.uuid})')
result = requests.get(url, headers=wger_headers()).json()
if result['count'] == 0: