Add ability to open recipes with specified number of servings from meal plan #2938
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When creating a meal plan, you can specify the number of servings to make which influences the amount of ingredients added to your shopping list. Then, when clicking the recipe from the plan it currently defaults to the recipe's default number of servings. Instead, this PR makes it so it defaults to the number in the meal plan. This only takes effect when navigating from the meal plan and should not interfere or change behavior elsewhere.
I have also added a toggle in the meal plan settings to enable/disable this functionality.
The loading of the correct number of servings is done by introducing an additional url format for recipes of /recipe/id-servings. If the -servings is omitted, it loads as normal. If it is included, the recipe will load with the specified number of servings.
I am open to any changes in the handling of this as well. I have limited knowledge of django and vue so if there is a better way to propagate the number of servings, I will happily implement it as such.
sample URL: http://127.0.0.1:8000/view/recipe/1-3 -- Opens recipe 1 with 3 servings
The modified Settings page: