Merge branch 'develop' into feature/keywords-rework

# Conflicts:
#	cookbook/static/vue/js/chunk-vendors.js
#	cookbook/static/vue/js/import_response_view.js
#	cookbook/static/vue/js/offline_view.js
#	cookbook/static/vue/js/recipe_search_view.js
#	cookbook/static/vue/js/recipe_view.js
#	cookbook/static/vue/js/supermarket_view.js
#	cookbook/static/vue/js/user_file_view.js
#	cookbook/templates/sw.js
#	cookbook/views/views.py
#	vue/src/components/RecipeCard.vue
#	vue/src/locales/en.json
This commit is contained in:
vabene1111
2021-06-30 14:57:33 +02:00
115 changed files with 14137 additions and 5122 deletions

View File

@@ -1,10 +1,11 @@
import json
import pytest
from django.db.models import Subquery, OuterRef
from django.urls import reverse
from django_scopes import scopes_disabled
from cookbook.models import Ingredient
from cookbook.models import Ingredient, Step
LIST_URL = 'api:ingredient-list'
DETAIL_URL = 'api:ingredient-detail'
@@ -28,6 +29,8 @@ def test_list_space(recipe_1_s1, u1_s1, u1_s2, space_2):
with scopes_disabled():
recipe_1_s1.space = space_2
recipe_1_s1.save()
Step.objects.update(space=Subquery(Step.objects.filter(pk=OuterRef('pk')).values('recipe__space')[:1]))
Ingredient.objects.update(space=Subquery(Ingredient.objects.filter(pk=OuterRef('pk')).values('step__recipe__space')[:1]))
assert len(json.loads(u1_s1.get(reverse(LIST_URL)).content)) == 0
assert len(json.loads(u1_s2.get(reverse(LIST_URL)).content)) == 10

View File

@@ -1,10 +1,11 @@
import json
import pytest
from django.db.models import Subquery, OuterRef
from django.urls import reverse
from django_scopes import scopes_disabled
from cookbook.models import Step
from cookbook.models import Step, Ingredient
LIST_URL = 'api:step-list'
DETAIL_URL = 'api:step-detail'
@@ -28,6 +29,8 @@ def test_list_space(recipe_1_s1, u1_s1, u1_s2, space_2):
with scopes_disabled():
recipe_1_s1.space = space_2
recipe_1_s1.save()
Step.objects.update(space=Subquery(Step.objects.filter(pk=OuterRef('pk')).values('recipe__space')[:1]))
Ingredient.objects.update(space=Subquery(Ingredient.objects.filter(pk=OuterRef('pk')).values('step__recipe__space')[:1]))
assert len(json.loads(u1_s1.get(reverse(LIST_URL)).content)) == 0
assert len(json.loads(u1_s2.get(reverse(LIST_URL)).content)) == 2

View File

@@ -51,8 +51,8 @@ def get_random_recipe(space_1, u1_s1):
internal=True,
)
s1 = Step.objects.create(name=uuid.uuid4(), instruction=uuid.uuid4(), )
s2 = Step.objects.create(name=uuid.uuid4(), instruction=uuid.uuid4(), )
s1 = Step.objects.create(name=uuid.uuid4(), instruction=uuid.uuid4(), space=space_1, )
s2 = Step.objects.create(name=uuid.uuid4(), instruction=uuid.uuid4(), space=space_1, )
r.steps.add(s1)
r.steps.add(s2)
@@ -64,6 +64,7 @@ def get_random_recipe(space_1, u1_s1):
food=Food.objects.create(name=uuid.uuid4(), space=space_1, ),
unit=Unit.objects.create(name=uuid.uuid4(), space=space_1, ),
note=uuid.uuid4(),
space=space_1,
)
)
@@ -73,6 +74,7 @@ def get_random_recipe(space_1, u1_s1):
food=Food.objects.create(name=uuid.uuid4(), space=space_1, ),
unit=Unit.objects.create(name=uuid.uuid4(), space=space_1, ),
note=uuid.uuid4(),
space=space_1,
)
)

View File

@@ -773,7 +773,7 @@ COOKPAD = {
"text": "Water",
"id": 49092
},
"note": "",
"note": "2-3",
"original": "2-3 c Water"
},
{
@@ -1498,10 +1498,10 @@ GIALLOZAFFERANO = {
"id": 64900
},
"ingredient": {
"text": "Pane (raffermo o secco) 80 g",
"text": "Pane 80 g",
"id": 24720
},
"note": "",
"note": "raffermo o secco",
"original": "Pane (raffermo o secco) 80 g"
},
{

View File

@@ -53,7 +53,12 @@ def test_ingredient_parser():
"50 g smör eller margarin": (50, "g", "smör eller margarin", ""),
"3,5 l Wasser": (3.5, "l", "Wasser", ""),
"3.5 l Wasser": (3.5, "l", "Wasser", ""),
"400 g Karotte(n)": (400, "g", "Karotte(n)", "")
"400 g Karotte(n)": (400, "g", "Karotte(n)", ""),
"400g unsalted butter": (400, "g", "butter", "unsalted"),
"2L Wasser": (2, "L", "Wasser", ""),
"1 (16 ounce) package dry lentils, rinsed": (1, "package", "dry lentils, rinsed", "16 ounce"),
"2-3 c Water": (2, "c", "Water", "2-3"),
"Pane (raffermo o secco) 80 g": (0, "", "Pane 80 g", "raffermo o secco"), #TODO this is actually not a good result but currently expected
}
# for German you could say that if an ingredient does not have
# an amount # and it starts with a lowercase letter, then that