fixed PR 2693
This commit is contained in:
@ -20,6 +20,10 @@ class Chowdown(Integration):
|
|||||||
direction_mode = False
|
direction_mode = False
|
||||||
description_mode = False
|
description_mode = False
|
||||||
|
|
||||||
|
description = None
|
||||||
|
prep_time = None
|
||||||
|
serving = None
|
||||||
|
|
||||||
ingredients = []
|
ingredients = []
|
||||||
directions = []
|
directions = []
|
||||||
descriptions = []
|
descriptions = []
|
||||||
@ -54,10 +58,11 @@ class Chowdown(Integration):
|
|||||||
if description_mode and len(line) > 3 and '---' not in line:
|
if description_mode and len(line) > 3 and '---' not in line:
|
||||||
descriptions.append(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(','):
|
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)
|
keyword, created = Keyword.objects.get_or_create(name=k.strip(), space=self.request.space)
|
||||||
recipe.keywords.add(keyword)
|
recipe.keywords.add(keyword)
|
||||||
|
|
||||||
@ -84,12 +89,12 @@ class Chowdown(Integration):
|
|||||||
food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space,
|
food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space,
|
||||||
))
|
))
|
||||||
recipe.steps.add(step)
|
recipe.steps.add(step)
|
||||||
|
|
||||||
if 'recipe_yield':
|
if serving:
|
||||||
recipe.servings = parse_servings(serving)
|
recipe.servings = parse_servings(serving)
|
||||||
recipe.servings_text = 'servings'
|
recipe.servings_text = 'servings'
|
||||||
|
|
||||||
if 'total_time' and prep_time is not None:
|
if prep_time:
|
||||||
recipe.working_time = parse_time(prep_time)
|
recipe.working_time = parse_time(prep_time)
|
||||||
|
|
||||||
ingredient_parser = IngredientParser(self.request, True)
|
ingredient_parser = IngredientParser(self.request, True)
|
||||||
@ -110,6 +115,7 @@ class Chowdown(Integration):
|
|||||||
if re.match(f'^images/{image}$', z.filename):
|
if re.match(f'^images/{image}$', z.filename):
|
||||||
self.import_recipe_image(recipe, BytesIO(import_zip.read(z.filename)), filetype=get_filetype(z.filename))
|
self.import_recipe_image(recipe, BytesIO(import_zip.read(z.filename)), filetype=get_filetype(z.filename))
|
||||||
|
|
||||||
|
recipe.save()
|
||||||
return recipe
|
return recipe
|
||||||
|
|
||||||
def get_file_from_recipe(self, recipe):
|
def get_file_from_recipe(self, recipe):
|
||||||
|
@ -58,8 +58,9 @@ class Mealie(Integration):
|
|||||||
|
|
||||||
if 'tags' in recipe_json and len(recipe_json['tags']) > 0:
|
if 'tags' in recipe_json and len(recipe_json['tags']) > 0:
|
||||||
for k in recipe_json['tags']:
|
for k in recipe_json['tags']:
|
||||||
keyword, created = Keyword.objects.get_or_create(name=k["name"].strip(), space=self.request.space)
|
if 'name' in k:
|
||||||
recipe.keywords.add(keyword)
|
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:
|
if 'notes' in recipe_json and len(recipe_json['notes']) > 0:
|
||||||
notes_text = "#### Notes \n\n"
|
notes_text = "#### Notes \n\n"
|
||||||
|
Reference in New Issue
Block a user