mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-09 16:18:00 -05:00
implement related recipes on home page
This commit is contained in:
@@ -65,7 +65,6 @@ def test_related_mixed_space(request, recipe, u1_s2):
|
|||||||
reverse(RELATED_URL, args={recipe.id})).content)) == 0
|
reverse(RELATED_URL, args={recipe.id})).content)) == 0
|
||||||
|
|
||||||
|
|
||||||
# TODO add tests for mealplan related when thats added
|
|
||||||
# TODO if/when related recipes includes multiple levels (related recipes of related recipes) add the following tests
|
# TODO if/when related recipes includes multiple levels (related recipes of related recipes) add the following tests
|
||||||
# -- step recipes included in step recipes
|
# -- step recipes included in step recipes
|
||||||
# -- step recipes included in food recipes
|
# -- step recipes included in food recipes
|
||||||
|
|||||||
@@ -229,7 +229,6 @@ def test_shopping_recipe_mixed_authors(u1_s1, u2_s1):
|
|||||||
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 adding recipe with ingredients that are not food
|
|
||||||
@pytest.mark.parametrize("recipe", [{'steps__ingredients__header': 1}], indirect=['recipe'])
|
@pytest.mark.parametrize("recipe", [{'steps__ingredients__header': 1}], indirect=['recipe'])
|
||||||
def test_shopping_with_header_ingredient(u1_s1, recipe):
|
def test_shopping_with_header_ingredient(u1_s1, recipe):
|
||||||
# with scope(space=recipe.space):
|
# with scope(space=recipe.space):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app" style="margin-bottom: 4vh">
|
<div id="app" style="margin-bottom: 4vh">
|
||||||
|
<RecipeSwitcher mode="mealplan" />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-xl-8 col-lg-10 offset-xl-2 offset-lg-1">
|
<div class="col-12 col-xl-8 col-lg-10 offset-xl-2 offset-lg-1">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -244,6 +245,7 @@ import RecipeCard from "@/components/RecipeCard"
|
|||||||
import GenericMultiselect from "@/components/GenericMultiselect"
|
import GenericMultiselect from "@/components/GenericMultiselect"
|
||||||
import Treeselect from "@riophae/vue-treeselect"
|
import Treeselect from "@riophae/vue-treeselect"
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css"
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css"
|
||||||
|
import RecipeSwitcher from "@/components/Buttons/RecipeSwitcher"
|
||||||
|
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
|
|
||||||
@@ -252,7 +254,7 @@ let SETTINGS_COOKIE_NAME = "search_settings"
|
|||||||
export default {
|
export default {
|
||||||
name: "RecipeSearchView",
|
name: "RecipeSearchView",
|
||||||
mixins: [ResolveUrlMixin, ApiMixin],
|
mixins: [ResolveUrlMixin, ApiMixin],
|
||||||
components: { GenericMultiselect, RecipeCard, Treeselect },
|
components: { GenericMultiselect, RecipeCard, Treeselect, RecipeSwitcher },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// this.Models and this.Actions inherited from ApiMixin
|
// this.Models and this.Actions inherited from ApiMixin
|
||||||
|
|||||||
@@ -34,9 +34,11 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
const { ApiApiFactory } = require("@/utils/openapi/api")
|
const { ApiApiFactory } = require("@/utils/openapi/api")
|
||||||
|
import { ResolveUrlMixin } from "@/utils/utils"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "RecipeSwitcher",
|
name: "RecipeSwitcher",
|
||||||
|
mixins: [ResolveUrlMixin],
|
||||||
props: {
|
props: {
|
||||||
recipe: { type: Number, default: undefined },
|
recipe: { type: Number, default: undefined },
|
||||||
name: { type: String, default: undefined },
|
name: { type: String, default: undefined },
|
||||||
@@ -64,7 +66,14 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.recipes = []
|
this.recipes = []
|
||||||
|
switch (this.mode) {
|
||||||
|
case "recipe":
|
||||||
this.loadRecipes()
|
this.loadRecipes()
|
||||||
|
break
|
||||||
|
case "mealplan":
|
||||||
|
this.loadMealPlans()
|
||||||
|
break
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@@ -74,7 +83,8 @@ export default {
|
|||||||
this.$emit("switch", recipe)
|
this.$emit("switch", recipe)
|
||||||
break
|
break
|
||||||
case "mealplan":
|
case "mealplan":
|
||||||
console.log("navigate to", recipe)
|
console.log("navigate to")
|
||||||
|
window.location.href = this.resolveDjangoUrl("view_recipe", recipe.id)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
console.log(this.mode, " isn't defined.")
|
console.log(this.mode, " isn't defined.")
|
||||||
@@ -82,7 +92,7 @@ export default {
|
|||||||
},
|
},
|
||||||
loadRecipes: function () {
|
loadRecipes: function () {
|
||||||
let apiClient = new ApiApiFactory()
|
let apiClient = new ApiApiFactory()
|
||||||
let today = new Date(Date.now()).toISOString().split("T")[0]
|
|
||||||
apiClient
|
apiClient
|
||||||
.relatedRecipe(this.recipe, { query: { levels: 2 } })
|
.relatedRecipe(this.recipe, { query: { levels: 2 } })
|
||||||
// get related recipes and save them for later
|
// get related recipes and save them for later
|
||||||
@@ -91,6 +101,12 @@ export default {
|
|||||||
})
|
})
|
||||||
// get all recipes for today
|
// get all recipes for today
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
this.loadMealPlans()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
loadMealPlans: function () {
|
||||||
|
let apiClient = new ApiApiFactory()
|
||||||
|
let today = new Date(Date.now()).toISOString().split("T")[0]
|
||||||
apiClient
|
apiClient
|
||||||
.listMealPlans({
|
.listMealPlans({
|
||||||
query: {
|
query: {
|
||||||
@@ -124,7 +140,6 @@ export default {
|
|||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user