fixed importer description overflow
This commit is contained in:
parent
94c51f90cd
commit
b1db591e9f
@ -16,8 +16,10 @@ class Mealie(Integration):
|
|||||||
def get_recipe_from_file(self, file):
|
def get_recipe_from_file(self, file):
|
||||||
recipe_json = json.loads(file.getvalue().decode("utf-8"))
|
recipe_json = json.loads(file.getvalue().decode("utf-8"))
|
||||||
|
|
||||||
|
description = '' if len(recipe_json['description'].strip()) > 500 else recipe_json['description'].strip()
|
||||||
|
|
||||||
recipe = Recipe.objects.create(
|
recipe = Recipe.objects.create(
|
||||||
name=recipe_json['name'].strip(), description=recipe_json['description'].strip(),
|
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)
|
||||||
|
|
||||||
# TODO parse times (given in PT2H3M )
|
# TODO parse times (given in PT2H3M )
|
||||||
@ -30,6 +32,9 @@ class Mealie(Integration):
|
|||||||
if not ingredients_added:
|
if not ingredients_added:
|
||||||
ingredients_added = True
|
ingredients_added = True
|
||||||
|
|
||||||
|
if len(recipe_json['description'].strip()) > 500:
|
||||||
|
step.instruction = recipe_json['description'].strip() + '\n\n' + step.instruction
|
||||||
|
|
||||||
for ingredient in recipe_json['recipeIngredient']:
|
for ingredient in recipe_json['recipeIngredient']:
|
||||||
amount, unit, ingredient, note = parse(ingredient)
|
amount, unit, ingredient, note = parse(ingredient)
|
||||||
f = get_food(ingredient, self.request.space)
|
f = get_food(ingredient, self.request.space)
|
||||||
|
@ -16,8 +16,10 @@ class NextcloudCookbook(Integration):
|
|||||||
def get_recipe_from_file(self, file):
|
def get_recipe_from_file(self, file):
|
||||||
recipe_json = json.loads(file.getvalue().decode("utf-8"))
|
recipe_json = json.loads(file.getvalue().decode("utf-8"))
|
||||||
|
|
||||||
|
description = '' if len(recipe_json['description'].strip()) > 500 else recipe_json['description'].strip()
|
||||||
|
|
||||||
recipe = Recipe.objects.create(
|
recipe = Recipe.objects.create(
|
||||||
name=recipe_json['name'].strip(), description=recipe_json['description'].strip(),
|
name=recipe_json['name'].strip(), description=description,
|
||||||
created_by=self.request.user, internal=True,
|
created_by=self.request.user, internal=True,
|
||||||
servings=recipe_json['recipeYield'], space=self.request.space)
|
servings=recipe_json['recipeYield'], space=self.request.space)
|
||||||
|
|
||||||
@ -30,6 +32,9 @@ class NextcloudCookbook(Integration):
|
|||||||
instruction=s
|
instruction=s
|
||||||
)
|
)
|
||||||
if not ingredients_added:
|
if not ingredients_added:
|
||||||
|
if len(recipe_json['description'].strip()) > 500:
|
||||||
|
step.instruction = recipe_json['description'].strip() + '\n\n' + step.instruction
|
||||||
|
|
||||||
ingredients_added = True
|
ingredients_added = True
|
||||||
|
|
||||||
for ingredient in recipe_json['recipeIngredient']:
|
for ingredient in recipe_json['recipeIngredient']:
|
||||||
|
@ -23,10 +23,10 @@ class Paprika(Integration):
|
|||||||
name=recipe_json['name'].strip(), created_by=self.request.user, internal=True, space=self.request.space)
|
name=recipe_json['name'].strip(), created_by=self.request.user, internal=True, space=self.request.space)
|
||||||
|
|
||||||
if 'description' in recipe_json:
|
if 'description' in recipe_json:
|
||||||
recipe.description = recipe_json['description'].strip()
|
recipe.description = '' if len(recipe_json['description'].strip()) > 500 else recipe_json['description'].strip()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if re.match(r'([0-9])+\s(.)*', recipe_json['servings'] ):
|
if re.match(r'([0-9])+\s(.)*', recipe_json['servings']):
|
||||||
s = recipe_json['servings'].split(' ')
|
s = recipe_json['servings'].split(' ')
|
||||||
recipe.servings = s[0]
|
recipe.servings = s[0]
|
||||||
recipe.servings_text = s[1]
|
recipe.servings_text = s[1]
|
||||||
@ -58,6 +58,9 @@ class Paprika(Integration):
|
|||||||
instruction=instructions
|
instruction=instructions
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if len(recipe_json['description'].strip()) > 500:
|
||||||
|
step.instruction = recipe_json['description'].strip() + '\n\n' + step.instruction
|
||||||
|
|
||||||
if 'categories' in recipe_json:
|
if 'categories' in recipe_json:
|
||||||
for c in recipe_json['categories']:
|
for c in recipe_json['categories']:
|
||||||
keyword, created = Keyword.objects.get_or_create(name=c.strip(), space=self.request.space)
|
keyword, created = Keyword.objects.get_or_create(name=c.strip(), space=self.request.space)
|
||||||
|
Loading…
Reference in New Issue
Block a user