Import recipe keywords

This commit is contained in:
its_me_gb
2021-05-01 15:02:22 +01:00
parent 5ef5530392
commit 7cd6a7c2a6

View File

@@ -9,7 +9,7 @@ from django.utils.translation import gettext as _
from cookbook.helper.ingredient_parser import parse, get_food, get_unit
from cookbook.integration.integration import Integration
from cookbook.models import Recipe, Step, Food, Unit, Ingredient
from cookbook.models import Recipe, Step, Food, Unit, Ingredient, Keyword
class RecetteTek(Integration):
@@ -95,6 +95,16 @@ class RecetteTek(Integration):
recipe.save()
# Import the recipe keywords
try:
if file['keywords'] != '':
for keyword in file['keywords'].split(';'):
k, created = Keyword.objects.get_or_create(name=keyword.strip(), space=self.request.space)
recipe.keywords.add(k)
recipe.save()
except Exception as e:
pass
# TODO: Parse Nutritional Information
# Import the original image from the zip file, if we cannot do that, attempt to download it again.