Fixed two issues adding recipe as ingredient to others #152
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.
Adresses two issues in reccard.py preventing a recipe from being added as an ingredient to another one.
Description
Tried adding a recipe as an ingredient to another:
Recipe -> Edit ingredients -> Add recipe
This raised:
Traceback (most recent call last): File "~/gourmand/reccard.py", line 1139, in <lambda> _('Add another recipe as an ingredient in this recipe'), lambda *args: RecSelector(self.rg, self)), File "~/gourmand/src/gourmand/reccard.py", line 2926, in __init__ RecIndex.__init__(self, File "~/gourmand/src/gourmand/recindex.py", line 64, in __init__ self.setup_widgets() File "~/gourmand/src/gourmand/recindex.py", line 139, in setup_widgets self.setup_search_views() File "~/src/gourmand/recindex.py", line 211, in setup_search_views sort_by=self.sort_by) File "~/gourmand/src/gourmand/reccard.py", line 2937, in sort_by column, ascending = preferences.values() ValueError: not enough values to unpack (expected 2, got 1)
Found the culprit in reccard.py, Line 2937, incompatible assignment:
column, ascending = preferences.values()
Fixed that and got a list of recipes to select. Selecting one and choosing an amount yielded a text box
"You haven't selected any recipes!" and after clicking "OK":
Traceback (most recent call last): File "~/gourmand/src/gourmand/reccard.py", line 2977, in rec_tree_select_rec self.ok() File "~/gourmand/src/gourmand/reccard.py", line 2998, in ok self.ingEditor.ingtree_ui.ingController.add_ingredient_from_kwargs( File "~/gourmand/src/gourmand/reccard.py", line 1752, in add_ingredient_from_kwargs self.update_ingredient_row( TypeError: IngredientController.update_ingredient_row() got an unexpected keyword argument 'refid'
Found that compared to older versions, def update_ingredient_row() omitted "refid" in its named parameters. It seemed ok for update_ingredient_row() to not actually handle "refid" as it seems to be done one up in add_ingredient_from_kwargs(), so I just added "refid" back to the parameters.
It seems to work well again. However I observed one new issue: Adding another recipe to the ingredients only, the "Save" button on the containing recipe stays grayed out. Adding and removing any other normal ingredient enables the button. The recipe can then be saved and works including the sub recipe reference.
How Has This Been Tested?
Created two test recipes with one simple ingredient each and yield property "1 Portion". Then tried adding one to the other as sub recipe.
Types of changes
Checklist: