mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-04 21:58:54 -05:00
fix categories in supermarket edit modal
This commit is contained in:
@@ -4,9 +4,10 @@ from datetime import datetime, timedelta
|
|||||||
import pytest
|
import pytest
|
||||||
from django.contrib import auth
|
from django.contrib import auth
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django_scopes import scopes_disabled
|
from django_scopes import scope, scopes_disabled
|
||||||
|
|
||||||
from cookbook.models import Food, MealPlan, MealType
|
from cookbook.models import Food, MealPlan, MealType
|
||||||
|
from cookbook.tests.factories import RecipeFactory
|
||||||
|
|
||||||
LIST_URL = 'api:mealplan-list'
|
LIST_URL = 'api:mealplan-list'
|
||||||
DETAIL_URL = 'api:mealplan-detail'
|
DETAIL_URL = 'api:mealplan-detail'
|
||||||
@@ -141,3 +142,17 @@ def test_delete(u1_s1, u1_s2, obj_1):
|
|||||||
assert r.status_code == 204
|
assert r.status_code == 204
|
||||||
with scopes_disabled():
|
with scopes_disabled():
|
||||||
assert MealPlan.objects.count() == 0
|
assert MealPlan.objects.count() == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_add_with_shopping(u1_s1, meal_type):
|
||||||
|
space = meal_type.space
|
||||||
|
with scope(space=space):
|
||||||
|
recipe = RecipeFactory.create(space=space)
|
||||||
|
r = u1_s1.post(
|
||||||
|
reverse(LIST_URL),
|
||||||
|
{'recipe': {'id': recipe.id, 'name': recipe.name, 'keywords': []}, 'meal_type': {'id': meal_type.id, 'name': meal_type.name},
|
||||||
|
'date': (datetime.now()).strftime("%Y-%m-%d"), 'servings': 1, 'title': 'test', 'shared': [], 'addshopping': True},
|
||||||
|
content_type='application/json'
|
||||||
|
)
|
||||||
|
|
||||||
|
assert len(json.loads(u1_s1.get(reverse('api:shoppinglistentry-list')).content)) == 10
|
||||||
|
|||||||
@@ -224,3 +224,6 @@ def test_shopping_recipe_mixed_authors(u1_s1, u2_s1):
|
|||||||
u1_s1.put(reverse(SHOPPING_RECIPE_URL, args={recipe1.id}))
|
u1_s1.put(reverse(SHOPPING_RECIPE_URL, args={recipe1.id}))
|
||||||
assert len(json.loads(u1_s1.get(reverse(SHOPPING_LIST_URL)).content)) == 29
|
assert len(json.loads(u1_s1.get(reverse(SHOPPING_LIST_URL)).content)) == 29
|
||||||
assert len(json.loads(u2_s1.get(reverse(SHOPPING_LIST_URL)).content)) == 0
|
assert len(json.loads(u2_s1.get(reverse(SHOPPING_LIST_URL)).content)) == 0
|
||||||
|
|
||||||
|
|
||||||
|
# TODO test failing to adding recipe with ingredients that are not food
|
||||||
|
|||||||
@@ -315,7 +315,6 @@ export default {
|
|||||||
this.genericAPI(this.this_model, this.Actions.MOVE, { source: source_id, target: target_id })
|
this.genericAPI(this.this_model, this.Actions.MOVE, { source: source_id, target: target_id })
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.moveUpdateItem(source_id, target_id)
|
this.moveUpdateItem(source_id, target_id)
|
||||||
// TODO make standard toast
|
|
||||||
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_MOVE)
|
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_MOVE)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@@ -355,7 +354,6 @@ export default {
|
|||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.mergeUpdateItem(source_id, target_id)
|
this.mergeUpdateItem(source_id, target_id)
|
||||||
// TODO make standard toast
|
|
||||||
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_MERGE)
|
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_MERGE)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@@ -416,7 +414,7 @@ export default {
|
|||||||
getRecipes: function (col, item) {
|
getRecipes: function (col, item) {
|
||||||
let parent = {}
|
let parent = {}
|
||||||
// TODO: make this generic
|
// TODO: make this generic
|
||||||
let params = { pageSize: 50 }
|
let params = { pageSize: 50, random: true }
|
||||||
params[this.this_recipe_param] = item.id
|
params[this.this_recipe_param] = item.id
|
||||||
console.log("RECIPE PARAM", this.this_recipe_param, params, item.id)
|
console.log("RECIPE PARAM", this.this_recipe_param, params, item.id)
|
||||||
this.genericAPI(this.Models.RECIPE, this.Actions.LIST, params)
|
this.genericAPI(this.Models.RECIPE, this.Actions.LIST, params)
|
||||||
|
|||||||
@@ -80,9 +80,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
arrayValues = [{ id: -1, name: this_value }]
|
arrayValues = [{ id: -1, name: this_value }]
|
||||||
}
|
}
|
||||||
|
if (this.form?.ordered && this.first_run && arrayValues.length > 0) {
|
||||||
console.log(arrayValues)
|
|
||||||
if (this.form?.ordered && this.first_run) {
|
|
||||||
return this.flattenItems(arrayValues)
|
return this.flattenItems(arrayValues)
|
||||||
} else {
|
} else {
|
||||||
return arrayValues
|
return arrayValues
|
||||||
|
|||||||
@@ -125,8 +125,6 @@ export default {
|
|||||||
entry.date = moment(entry.date).format("YYYY-MM-DD")
|
entry.date = moment(entry.date).format("YYYY-MM-DD")
|
||||||
|
|
||||||
let apiClient = new ApiApiFactory()
|
let apiClient = new ApiApiFactory()
|
||||||
console.log("etnry", entry)
|
|
||||||
|
|
||||||
apiClient
|
apiClient
|
||||||
.createMealPlan(entry)
|
.createMealPlan(entry)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ export function getForm(model, action, item1, item2) {
|
|||||||
if (f === "partialUpdate" && Object.keys(config).length == 0) {
|
if (f === "partialUpdate" && Object.keys(config).length == 0) {
|
||||||
config = { ...Actions.CREATE?.form, ...model.model_type?.["create"]?.form, ...model?.["create"]?.form }
|
config = { ...Actions.CREATE?.form, ...model.model_type?.["create"]?.form, ...model?.["create"]?.form }
|
||||||
config["title"] = { ...action?.form_title, ...model.model_type?.[f]?.form_title, ...model?.[f]?.form_title }
|
config["title"] = { ...action?.form_title, ...model.model_type?.[f]?.form_title, ...model?.[f]?.form_title }
|
||||||
if (config["form_function"].includes("Create")) {
|
if (config?.["form_function"]?.includes("Create")) {
|
||||||
delete config["form_function"]
|
delete config["form_function"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user