Skip to content

Commit

Permalink
fixed PR 2693
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Nov 27, 2023
1 parent 5e91829 commit 1145a8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 11 additions & 5 deletions cookbook/integration/chowdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def get_recipe_from_file(self, file):
direction_mode = False
description_mode = False

description = None
prep_time = None
serving = None

ingredients = []
directions = []
descriptions = []
Expand Down Expand Up @@ -54,10 +58,11 @@ def get_recipe_from_file(self, file):
if description_mode and len(line) > 3 and '---' not in line:
descriptions.append(line)

recipe = Recipe.objects.create(name=title, description=description, created_by=self.request.user, internal=True, space=self.request.space)
recipe = Recipe.objects.create(name=title, created_by=self.request.user, internal=True, space=self.request.space)
if description:
recipe.description = description

for k in tags.split(','):
print(f'adding keyword {k.strip()}')
keyword, created = Keyword.objects.get_or_create(name=k.strip(), space=self.request.space)
recipe.keywords.add(keyword)

Expand All @@ -84,12 +89,12 @@ def get_recipe_from_file(self, file):
food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space,
))
recipe.steps.add(step)
if 'recipe_yield':

if serving:
recipe.servings = parse_servings(serving)
recipe.servings_text = 'servings'

if 'total_time' and prep_time is not None:
if prep_time:
recipe.working_time = parse_time(prep_time)

ingredient_parser = IngredientParser(self.request, True)
Expand All @@ -110,6 +115,7 @@ def get_recipe_from_file(self, file):
if re.match(f'^images/{image}$', z.filename):
self.import_recipe_image(recipe, BytesIO(import_zip.read(z.filename)), filetype=get_filetype(z.filename))

recipe.save()
return recipe

def get_file_from_recipe(self, recipe):
Expand Down
5 changes: 3 additions & 2 deletions cookbook/integration/mealie.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ def get_recipe_from_file(self, file):

if 'tags' in recipe_json and len(recipe_json['tags']) > 0:
for k in recipe_json['tags']:
keyword, created = Keyword.objects.get_or_create(name=k["name"].strip(), space=self.request.space)
recipe.keywords.add(keyword)
if 'name' in k:
keyword, created = Keyword.objects.get_or_create(name=k['name'].strip(), space=self.request.space)
recipe.keywords.add(keyword)

if 'notes' in recipe_json and len(recipe_json['notes']) > 0:
notes_text = "#### Notes \n\n"
Expand Down

0 comments on commit 1145a8c

Please sign in to comment.