fixed access for shared recipes

This commit is contained in:
vabene1111
2021-01-13 22:59:19 +01:00
parent 910dc29f06
commit 50829dce47
4 changed files with 11 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -65,9 +65,10 @@
<script type="application/javascript">
window.RECIPE_ID = {{recipe.pk}};
window.USER_SERVINGS = {{ user_servings }};
window.SHARE_UID = '{{ share }}';
window.USER_PREF = {
'use_fractions': {% if request.user.userpreference.use_fractions %} true {% else %} false {% endif %},
'ingredient_decimals': {{ request.user.userpreference.ingredient_decimals }},
'ingredient_decimals': {% if request.user.userpreference.use_fractions %} {{ request.user.userpreference.ingredient_decimals }} {% else %} 2 {% endif %},
}
</script>

View File

@ -6,11 +6,15 @@ axios.defaults.xsrfCookieName = 'csrftoken'
axios.defaults.xsrfHeaderName = "X-CSRFTOKEN"
export function apiLoadRecipe(recipe_id) {
return axios.get(resolveDjangoUrl('api:recipe-detail', recipe_id)).then((response) => {
let url = resolveDjangoUrl('api:recipe-detail', recipe_id)
if (window.SHARE_UID !== undefined) {
url += '?share=' + window.SHARE_UID
}
return axios.get(url).then((response) => {
return response.data
}).catch((err) => {
console.log(err.response)
makeToast('Error', 'There was an error loading a resource!', 'danger')
handleError(err, 'There was an error loading a resource!', 'danger')
})
}

View File

@ -1 +1 @@
{"status":"compiling","publicPath":"http://localhost:8080/"}
{"status":"done","chunks":{"chunk-vendors":[{"name":"css/chunk-vendors.css","path":"F:\\Developement\\Django\\recipes\\cookbook\\static\\vue\\css\\chunk-vendors.css"},{"name":"js/chunk-vendors.js","path":"F:\\Developement\\Django\\recipes\\cookbook\\static\\vue\\js\\chunk-vendors.js"}],"recipe_view":[{"name":"js/recipe_view.js","path":"F:\\Developement\\Django\\recipes\\cookbook\\static\\vue\\js\\recipe_view.js"}]}}