mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 12:18:45 -05:00
more cleanup from ugly merge
This commit is contained in:
@@ -539,9 +539,17 @@ def recipe_from_json(request):
|
||||
mjson = request.POST['json']
|
||||
|
||||
md_json = json.loads(mjson)
|
||||
if ('@type' in md_json
|
||||
and md_json['@type'] == 'Recipe'):
|
||||
return JsonResponse(find_recipe_json(md_json, ''))
|
||||
for ld_json_item in md_json:
|
||||
# recipes type might be wrapped in @graph type
|
||||
if '@graph' in ld_json_item:
|
||||
for x in md_json['@graph']:
|
||||
if '@type' in x and x['@type'] == 'Recipe':
|
||||
md_json = x
|
||||
|
||||
if ('@type' in md_json
|
||||
and md_json['@type'] == 'Recipe'):
|
||||
return JsonResponse(find_recipe_json(md_json, '', request.space))
|
||||
|
||||
return JsonResponse(
|
||||
{
|
||||
'error': True,
|
||||
@@ -608,14 +616,14 @@ def recipe_from_url_old(request):
|
||||
|
||||
|
||||
@group_required('user')
|
||||
def recipe_from_html(request):
|
||||
html_data = request.POST['html_data']
|
||||
recipe_json, recipe_tree = get_from_raw(html_data)
|
||||
def manual_recipe_from_json(request):
|
||||
json_data = request.POST['data']
|
||||
recipe_json, recipe_tree = get_from_raw(json_data)
|
||||
if len(recipe_tree) == 0 and len(recipe_json) == 0:
|
||||
return JsonResponse(
|
||||
{
|
||||
'error': True,
|
||||
'msg': _('The requested page refused to provide any information (Status Code 403).') # noqa: E501
|
||||
'msg': _('No useable data could be found.') # noqa: E501
|
||||
},
|
||||
status=400
|
||||
)
|
||||
@@ -631,26 +639,6 @@ def get_backup(request):
|
||||
if not request.user.is_superuser:
|
||||
return HttpResponse('', status=403)
|
||||
|
||||
md_json = json.loads(mjson)
|
||||
for ld_json_item in md_json:
|
||||
# recipes type might be wrapped in @graph type
|
||||
if '@graph' in ld_json_item:
|
||||
for x in md_json['@graph']:
|
||||
if '@type' in x and x['@type'] == 'Recipe':
|
||||
md_json = x
|
||||
|
||||
if ('@type' in md_json
|
||||
and md_json['@type'] == 'Recipe'):
|
||||
return JsonResponse(find_recipe_json(md_json, '', request.space))
|
||||
|
||||
return JsonResponse(
|
||||
{
|
||||
'error': True,
|
||||
'msg': _('Could not parse correctly...')
|
||||
},
|
||||
status=400
|
||||
)
|
||||
|
||||
|
||||
@group_required('user')
|
||||
def ingredient_from_string(request):
|
||||
|
||||
@@ -129,10 +129,10 @@ def import_url(request):
|
||||
recipe.steps.add(step)
|
||||
|
||||
for kw in data['keywords']:
|
||||
if kw['id'] != "null" and (k := Keyword.objects.filter(id=kw['id'], space=request.space).first()):
|
||||
if k := Keyword.objects.filter(name=kw['text'], space=request.space).first():
|
||||
recipe.keywords.add(k)
|
||||
elif data['all_keywords']:
|
||||
k = Keyword.objects.create(name=kw['text'], space=request.space)
|
||||
k = Keyword.objects.create(name=kw['text'])
|
||||
recipe.keywords.add(k)
|
||||
|
||||
for ing in data['recipeIngredient']:
|
||||
|
||||
Reference in New Issue
Block a user