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

@@ -80,7 +80,7 @@
<div class="col-md-1">
<input class="form-control" v-model="i.amount">
</div>
<div class="col-md-5">
<div class="col-md-4">
<table class="table-layout:fixed">
<col width="95%"/>
@@ -119,7 +119,7 @@
</div>
<div class="col-md-5">
<div class="col-md-4">
<multiselect v-tabindex
ref="ingredient"
@@ -143,6 +143,9 @@
</multiselect>
</div>
<div class="col-md-2">
<input type="text" placeholder="{% trans 'Note' %}" class="form-control" v-model="i.note">
</div>
<div class="col-md-1">
<button class="btn btn-outline-danger btn-lg" type="button"
@click="deleteIngredient(i)" tabindex="-1"><i

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'])