mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
WIP
This commit is contained in:
@@ -131,23 +131,25 @@ def import_url(request):
|
|||||||
recipe.steps.add(step)
|
recipe.steps.add(step)
|
||||||
|
|
||||||
for kw in data['keywords']:
|
for kw in data['keywords']:
|
||||||
if k := Keyword.objects.filter(name=kw['text'], space=request.space).first():
|
# if k := Keyword.objects.filter(name=kw['text'], space=request.space).first():
|
||||||
recipe.keywords.add(k)
|
# recipe.keywords.add(k)
|
||||||
elif data['all_keywords']:
|
# elif data['all_keywords']:
|
||||||
k = Keyword.objects.create(name=kw['text'], space=request.space)
|
# k = Keyword.objects.create(name=kw['text'], space=request.space)
|
||||||
recipe.keywords.add(k)
|
# 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']:
|
for ing in data['recipeIngredient']:
|
||||||
ingredient = Ingredient()
|
ingredient = Ingredient()
|
||||||
|
|
||||||
if ing['ingredient']['text'] != '':
|
if ing['ingredient']['text'] != '':
|
||||||
ingredient.food, f_created = Food.objects.get_or_create(
|
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'] != '':
|
if ing['unit'] and ing['unit']['text'] != '':
|
||||||
ingredient.unit, u_created = Unit.objects.get_or_create(
|
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
|
# TODO properly handle no_amount recipes
|
||||||
|
|||||||
Reference in New Issue
Block a user