fixed mealie import no steps but ingredients

This commit is contained in:
vabene1111
2023-03-14 22:58:35 +01:00
parent f29f77a1d5
commit bbcf7ba8a7

View File

@ -24,13 +24,14 @@ class Mealie(Integration):
name=recipe_json['name'].strip(), description=description, name=recipe_json['name'].strip(), description=description,
created_by=self.request.user, internal=True, space=self.request.space) created_by=self.request.user, internal=True, space=self.request.space)
ingredients_added = False
for s in recipe_json['recipe_instructions']: for s in recipe_json['recipe_instructions']:
step = Step.objects.create( step = Step.objects.create(instruction=s['text'], space=self.request.space, )
instruction=s['text'], space=self.request.space, recipe.steps.add(step)
)
if not ingredients_added: step = recipe.steps.first()
ingredients_added = True if not step: # if there is no step in the exported data
step = Step.objects.create(instruction='', space=self.request.space, )
recipe.steps.add(step)
if len(recipe_json['description'].strip()) > 500: if len(recipe_json['description'].strip()) > 500:
step.instruction = recipe_json['description'].strip() + '\n\n' + step.instruction step.instruction = recipe_json['description'].strip() + '\n\n' + step.instruction
@ -54,7 +55,6 @@ class Mealie(Integration):
)) ))
except Exception: except Exception:
pass pass
recipe.steps.add(step)
if 'notes' in recipe_json and len(recipe_json['notes']) > 0: if 'notes' in recipe_json and len(recipe_json['notes']) > 0:
notes_text = "#### Notes \n\n" notes_text = "#### Notes \n\n"