added note support for recipe import

This commit is contained in:
vabene1111
2020-09-01 11:49:19 +02:00
parent 4e92be3bbc
commit 62868cd2b2
2 changed files with 9 additions and 3 deletions

View File

@ -126,6 +126,7 @@ def import_url(request):
else:
u = Unit.objects.get(name=request.user.userpreference.default_unit)
# TODO properly handl no_amount recipes
if isinstance(ing['amount'], str):
try:
ing['amount'] = float(ing['amount'].replace(',', '.'))
@ -133,7 +134,9 @@ def import_url(request):
# TODO return proper error
pass
step.ingredients.add(Ingredient.objects.create(food=f, unit=u, amount=ing['amount']))
note = ing['note'] if 'note' in ing else ''
step.ingredients.add(Ingredient.objects.create(food=f, unit=u, amount=ing['amount'], note=note))
if data['image'] != '':
response = requests.get(data['image'])