diff --git a/cookbook/views/data.py b/cookbook/views/data.py index fe6afde33..ab7c7a120 100644 --- a/cookbook/views/data.py +++ b/cookbook/views/data.py @@ -131,23 +131,25 @@ def import_url(request): recipe.steps.add(step) for kw in data['keywords']: - if k := Keyword.objects.filter(name=kw['text'], space=request.space).first(): - recipe.keywords.add(k) - elif data['all_keywords']: - k = Keyword.objects.create(name=kw['text'], space=request.space) - recipe.keywords.add(k) + # if k := Keyword.objects.filter(name=kw['text'], space=request.space).first(): + # recipe.keywords.add(k) + # elif data['all_keywords']: + # k = Keyword.objects.create(name=kw['text'], space=request.space) + # recipe.keywords.add(k) + k = Keyword.objects.get_or_create(name=kw['text'].strip(), space=request.space) + recipe.keywords.add(k) for ing in data['recipeIngredient']: ingredient = Ingredient() if ing['ingredient']['text'] != '': ingredient.food, f_created = Food.objects.get_or_create( - name=ing['ingredient']['text'], space=request.space + name=ing['ingredient']['text'].strip(), space=request.space ) if ing['unit'] and ing['unit']['text'] != '': ingredient.unit, u_created = Unit.objects.get_or_create( - name=ing['unit']['text'], space=request.space + name=ing['unit']['text'].strip(), space=request.space ) # TODO properly handle no_amount recipes