Merge branch 'develop' into feature/importer_to_vue

# Conflicts:
#	cookbook/helper/recipe_url_import.py
This commit is contained in:
vabene1111
2022-03-04 14:33:59 +01:00
60 changed files with 1172 additions and 1172 deletions

View File

@@ -156,7 +156,7 @@ def import_url(request):
recipe.steps.add(step)
for kw in data['keywords']:
if data['all_keywords']: # do not remove this check :) https://github.com/vabene1111/recipes/issues/645
if data['all_keywords']: # do not remove this check :) https://github.com/vabene1111/recipes/issues/645
k, created = Keyword.objects.get_or_create(name=kw['text'], space=request.space)
recipe.keywords.add(k)
else:
@@ -168,7 +168,8 @@ def import_url(request):
ingredient_parser = IngredientParser(request, True)
for ing in data['recipeIngredient']:
ingredient = Ingredient(space=request.space, )
original = ing.pop('original', None) or ing.pop('original_text', None)
ingredient = Ingredient(original_text=original, space=request.space, )
if food_text := ing['ingredient']['text'].strip():
ingredient.food = ingredient_parser.get_food(food_text)

View File

@@ -11,6 +11,7 @@ from django.utils.translation import gettext as _
from cookbook.forms import ExportForm, ImportExportBase, ImportForm
from cookbook.helper.permission_helper import group_required
from cookbook.helper.recipe_search import RecipeSearch
from cookbook.integration.cheftap import ChefTap
from cookbook.integration.chowdown import Chowdown
from cookbook.integration.cookbookapp import CookBookApp
@@ -123,6 +124,9 @@ def export_recipe(request):
recipes = form.cleaned_data['recipes']
if form.cleaned_data['all']:
recipes = Recipe.objects.filter(space=request.space, internal=True).all()
elif custom_filter := form.cleaned_data['custom_filter']:
search = RecipeSearch(request, filter=custom_filter)
recipes = search.get_queryset(Recipe.objects.filter(space=request.space, internal=True))
integration = get_integration(request, form.cleaned_data['type'])

View File

@@ -48,11 +48,11 @@ def hook(request, token):
request.space = tb.space # TODO this is likely a bad idea. Verify and test
request.user = tb.created_by
ingredient_parser = IngredientParser(request, False)
amount, unit, ingredient, note = ingredient_parser.parse(data['message']['text'])
f = ingredient_parser.get_food(ingredient)
amount, unit, food, note = ingredient_parser.parse(data['message']['text'])
f = ingredient_parser.get_food(food)
u = ingredient_parser.get_unit(unit)
ShoppingListEntry.objects.create(food=f, unit=u, amount=amount, created_by=request.user, space=request.space)
ShoppingListEntry.objects.create(food=f, unit=u, amount=amount, original_text=ingredient, created_by=request.user, space=request.space)
return JsonResponse({'data': data['message']['text']})
except Exception: