From 6385866e98df4c95398d183cefcd7efb1a06a6c5 Mon Sep 17 00:00:00 2001 From: smilerz Date: Mon, 8 Jul 2024 08:35:59 -0500 Subject: [PATCH] url import fixes --- cookbook/helper/recipe_url_import.py | 4 ++-- cookbook/views/api.py | 2 +- requirements.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cookbook/helper/recipe_url_import.py b/cookbook/helper/recipe_url_import.py index eca6813aaf..a6d91f84c5 100644 --- a/cookbook/helper/recipe_url_import.py +++ b/cookbook/helper/recipe_url_import.py @@ -373,8 +373,8 @@ def parse_servings(servings): servings = 1 elif isinstance(servings, list): try: - servings = int(re.findall(r'\b\d+\b', servings[0])[0]) - except KeyError: + servings = int(re.findall(r'\b\d+\b', str(servings[0]))[0]) + except (KeyError, IndexError): servings = 1 return servings diff --git a/cookbook/views/api.py b/cookbook/views/api.py index f890caeaa9..3c2d596b21 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -861,7 +861,7 @@ def get_queryset(self): if unit and re.match(r'^(\d)+$', unit): queryset = queryset.filter(unit_id=unit) - return queryset + return queryset.select_related('food') class StepViewSet(viewsets.ModelViewSet): diff --git a/requirements.txt b/requirements.txt index 56788a7052..0e4924d3c0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,7 +30,7 @@ Jinja2==3.1.4 django-webpack-loader==3.0.1 git+https://github.com/BITSOLVER/django-js-reverse@071e304fd600107bc64bbde6f2491f1fe049ec82 django-allauth==0.61.1 -recipe-scrapers==15.0.0-rc2 +recipe-scrapers==15.0.0-rc3 django-scopes==2.0.0 django-treebeard==4.7 django-cors-headers==4.3.1