nextcloud import working with images

This commit is contained in:
vabene1111
2021-02-08 19:19:56 +01:00
parent 7d051336d3
commit 149c5b5f5e
2 changed files with 11 additions and 1 deletions

View File

@ -25,7 +25,7 @@ class NextcloudCookbook(Integration):
created_by=self.request.user, internal=True,
servings=recipe_json['recipeYield'])
#TODO parse times (given in PT2H3M )
# TODO parse times (given in PT2H3M )
ingredients_added = False
for s in recipe_json['recipeInstructions']:
@ -44,6 +44,13 @@ class NextcloudCookbook(Integration):
))
recipe.steps.add(step)
for f in self.files:
if '.zip' in f.name:
import_zip = ZipFile(f.file)
for z in import_zip.filelist:
if re.match(f'^Recipes/{recipe.name}/full.jpg$', z.filename):
self.import_recipe_image(recipe, BytesIO(import_zip.read(z.filename)))
return recipe
def get_file_from_recipe(self, recipe):