fixed nextcloud import how to step
This commit is contained in:
@ -51,6 +51,12 @@ class NextcloudCookbook(Integration):
|
|||||||
|
|
||||||
ingredients_added = False
|
ingredients_added = False
|
||||||
for s in recipe_json['recipeInstructions']:
|
for s in recipe_json['recipeInstructions']:
|
||||||
|
instruction_text = ''
|
||||||
|
if 'text' in s:
|
||||||
|
step = Step.objects.create(
|
||||||
|
instruction=s['text'], name=s['name'], space=self.request.space,
|
||||||
|
)
|
||||||
|
else:
|
||||||
step = Step.objects.create(
|
step = Step.objects.create(
|
||||||
instruction=s, space=self.request.space,
|
instruction=s, space=self.request.space,
|
||||||
)
|
)
|
||||||
@ -98,11 +104,10 @@ class NextcloudCookbook(Integration):
|
|||||||
return recipe
|
return recipe
|
||||||
|
|
||||||
def formatTime(self, min):
|
def formatTime(self, min):
|
||||||
h = min//60
|
h = min // 60
|
||||||
m = min % 60
|
m = min % 60
|
||||||
return f'PT{h}H{m}M0S'
|
return f'PT{h}H{m}M0S'
|
||||||
|
|
||||||
|
|
||||||
def get_file_from_recipe(self, recipe):
|
def get_file_from_recipe(self, recipe):
|
||||||
|
|
||||||
export = {}
|
export = {}
|
||||||
@ -111,7 +116,7 @@ class NextcloudCookbook(Integration):
|
|||||||
export['url'] = recipe.source_url
|
export['url'] = recipe.source_url
|
||||||
export['prepTime'] = self.formatTime(recipe.working_time)
|
export['prepTime'] = self.formatTime(recipe.working_time)
|
||||||
export['cookTime'] = self.formatTime(recipe.waiting_time)
|
export['cookTime'] = self.formatTime(recipe.waiting_time)
|
||||||
export['totalTime'] = self.formatTime(recipe.working_time+recipe.waiting_time)
|
export['totalTime'] = self.formatTime(recipe.working_time + recipe.waiting_time)
|
||||||
export['recipeYield'] = recipe.servings
|
export['recipeYield'] = recipe.servings
|
||||||
export['image'] = f'/Recipes/{recipe.name}/full.jpg'
|
export['image'] = f'/Recipes/{recipe.name}/full.jpg'
|
||||||
export['imageUrl'] = f'/Recipes/{recipe.name}/full.jpg'
|
export['imageUrl'] = f'/Recipes/{recipe.name}/full.jpg'
|
||||||
@ -133,7 +138,6 @@ class NextcloudCookbook(Integration):
|
|||||||
export['recipeIngredient'] = recipeIngredient
|
export['recipeIngredient'] = recipeIngredient
|
||||||
export['recipeInstructions'] = recipeInstructions
|
export['recipeInstructions'] = recipeInstructions
|
||||||
|
|
||||||
|
|
||||||
return "recipe.json", json.dumps(export)
|
return "recipe.json", json.dumps(export)
|
||||||
|
|
||||||
def get_files_from_recipes(self, recipes, el, cookie):
|
def get_files_from_recipes(self, recipes, el, cookie):
|
||||||
@ -163,7 +167,7 @@ class NextcloudCookbook(Integration):
|
|||||||
|
|
||||||
export_zip_obj.close()
|
export_zip_obj.close()
|
||||||
|
|
||||||
return [[ self.get_export_file_name(), export_zip_stream.getvalue() ]]
|
return [[self.get_export_file_name(), export_zip_stream.getvalue()]]
|
||||||
|
|
||||||
def getJPEG(self, imageByte):
|
def getJPEG(self, imageByte):
|
||||||
image = Image.open(BytesIO(imageByte))
|
image = Image.open(BytesIO(imageByte))
|
||||||
@ -179,7 +183,7 @@ class NextcloudCookbook(Integration):
|
|||||||
w, h = image.size
|
w, h = image.size
|
||||||
m = min(w, h)
|
m = min(w, h)
|
||||||
|
|
||||||
image = image.crop(((w-m)//2, (h-m)//2, (w+m)//2, (h+m)//2))
|
image = image.crop(((w - m) // 2, (h - m) // 2, (w + m) // 2, (h + m) // 2))
|
||||||
image = image.resize([size, size], Image.Resampling.LANCZOS)
|
image = image.resize([size, size], Image.Resampling.LANCZOS)
|
||||||
image = image.convert('RGB')
|
image = image.convert('RGB')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user