fixed import error

This commit is contained in:
vabene1111
2020-06-23 14:00:07 +02:00
parent 3ef82aee9c
commit 73f2240763
3 changed files with 7 additions and 4 deletions

View File

@ -105,7 +105,7 @@ def find_recipe_json(ld_json, url):
else: else:
ld_json['recipeInstructions'] = '' ld_json['recipeInstructions'] = ''
ld_json['recipeInstructions'] += _('Imported from ') + url ld_json['recipeInstructions'] += '\n\n' + _('Imported from ') + url
if 'image' in ld_json: if 'image' in ld_json:
# check if list of images is returned, take first if so # check if list of images is returned, take first if so

View File

@ -86,7 +86,7 @@
:options="units" :options="units"
:close-on-select="true" :close-on-select="true"
:clear-on-select="true" :clear-on-select="true"
:hide-selected="true"
:preserve-search="true" :preserve-search="true"
placeholder="{% trans 'Select one' %}" placeholder="{% trans 'Select one' %}"
tag-placeholder="{% trans 'Create new' %}" tag-placeholder="{% trans 'Create new' %}"
@ -110,7 +110,7 @@
tag-placeholder="{% trans 'Create new' %}" tag-placeholder="{% trans 'Create new' %}"
:close-on-select="true" :close-on-select="true"
:clear-on-select="true" :clear-on-select="true"
:hide-selected="true"
:preserve-search="true" :preserve-search="true"
label="text" label="text"
:id="index" :id="index"

View File

@ -116,7 +116,10 @@ def import_url(request):
for ing in data['recipeIngredient']: for ing in data['recipeIngredient']:
i, i_created = Ingredient.objects.get_or_create(name=ing['ingredient']['text']) i, i_created = Ingredient.objects.get_or_create(name=ing['ingredient']['text'])
if ing['unit']:
u, u_created = Unit.objects.get_or_create(name=ing['unit']['text']) u, u_created = Unit.objects.get_or_create(name=ing['unit']['text'])
else:
u = Unit.objects.get(name=request.user.userpreference.default_unit)
if isinstance(ing['amount'], str): if isinstance(ing['amount'], str):
try: try: