mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-05 06:08:46 -05:00
importing improvements
This commit is contained in:
@@ -291,7 +291,7 @@ def recipe_from_url(request, url):
|
||||
ld_json_item = x
|
||||
|
||||
if '@type' in ld_json_item and ld_json_item['@type'] == 'Recipe':
|
||||
return find_recipe_json(ld_json_item)
|
||||
return find_recipe_json(ld_json_item, url)
|
||||
except JSONDecodeError:
|
||||
JsonResponse({'error': True, 'msg': _('The requested site does not provided malformed data and cannot be read.')}, status=400)
|
||||
|
||||
@@ -300,6 +300,6 @@ def recipe_from_url(request, url):
|
||||
for i in items:
|
||||
md_json = json.loads(i.json())
|
||||
if 'schema.org/Recipe' in str(md_json['type']):
|
||||
return find_recipe_json(md_json['properties'])
|
||||
return find_recipe_json(md_json['properties'], url)
|
||||
|
||||
return JsonResponse({'error': True, 'msg': _('The requested site does not provide any recognized data format to import the recipe from.')}, status=400)
|
||||
|
||||
@@ -101,6 +101,8 @@ def import_url(request):
|
||||
recipe = Recipe.objects.create(
|
||||
name=data['name'],
|
||||
instructions=data['recipeInstructions'],
|
||||
waiting_time=data['cookTime'],
|
||||
working_time=data['prepTime'],
|
||||
internal=True,
|
||||
created_by=request.user,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user