mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-31 02:28:00 -04:00 
			
		
		
		
	Fix for shopping list recipe delete route (#1954)
* fixed broken types * changed remove recipe route from delete to post
This commit is contained in:
		
							parent
							
								
									46cc3898ab
								
							
						
					
					
						commit
						c4eebaccca
					
				| @ -15,6 +15,7 @@ const routes = { | |||||||
|   shoppingLists: `${prefix}/groups/shopping/lists`, |   shoppingLists: `${prefix}/groups/shopping/lists`, | ||||||
|   shoppingListsId: (id: string) => `${prefix}/groups/shopping/lists/${id}`, |   shoppingListsId: (id: string) => `${prefix}/groups/shopping/lists/${id}`, | ||||||
|   shoppingListIdAddRecipe: (id: string, recipeId: string) => `${prefix}/groups/shopping/lists/${id}/recipe/${recipeId}`, |   shoppingListIdAddRecipe: (id: string, recipeId: string) => `${prefix}/groups/shopping/lists/${id}/recipe/${recipeId}`, | ||||||
|  |   shoppingListIdRemoveRecipe: (id: string, recipeId: string) => `${prefix}/groups/shopping/lists/${id}/recipe/${recipeId}/delete`, | ||||||
| 
 | 
 | ||||||
|   shoppingListItems: `${prefix}/groups/shopping/items`, |   shoppingListItems: `${prefix}/groups/shopping/items`, | ||||||
|   shoppingListItemsId: (id: string) => `${prefix}/groups/shopping/items/${id}`, |   shoppingListItemsId: (id: string) => `${prefix}/groups/shopping/items/${id}`, | ||||||
| @ -28,8 +29,8 @@ export class ShoppingListsApi extends BaseCRUDAPI<ShoppingListCreate, ShoppingLi | |||||||
|     return await this.requests.post(routes.shoppingListIdAddRecipe(itemId, recipeId), {recipeIncrementQuantity}); |     return await this.requests.post(routes.shoppingListIdAddRecipe(itemId, recipeId), {recipeIncrementQuantity}); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async removeRecipe(itemId: string, recipeId: string) { |   async removeRecipe(itemId: string, recipeId: string, recipeDecrementQuantity = 1) { | ||||||
|     return await this.requests.delete(routes.shoppingListIdAddRecipe(itemId, recipeId)); |     return await this.requests.post(routes.shoppingListIdRemoveRecipe(itemId, recipeId), {recipeDecrementQuantity}); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -268,7 +268,7 @@ class ShoppingListController(BaseCrudController): | |||||||
| 
 | 
 | ||||||
|         return shopping_list |         return shopping_list | ||||||
| 
 | 
 | ||||||
|     @router.delete("/{item_id}/recipe/{recipe_id}", response_model=ShoppingListOut) |     @router.post("/{item_id}/recipe/{recipe_id}/delete", response_model=ShoppingListOut) | ||||||
|     def remove_recipe_ingredients_from_list( |     def remove_recipe_ingredients_from_list( | ||||||
|         self, item_id: UUID4, recipe_id: UUID4, data: ShoppingListRemoveRecipeParams | None = None |         self, item_id: UUID4, recipe_id: UUID4, data: ShoppingListRemoveRecipeParams | None = None | ||||||
|     ): |     ): | ||||||
|  | |||||||
| @ -202,8 +202,9 @@ def test_shopping_lists_remove_recipe( | |||||||
|         assert item["note"] in known_ingredients |         assert item["note"] in known_ingredients | ||||||
| 
 | 
 | ||||||
|     # Remove Recipe |     # Remove Recipe | ||||||
|     response = api_client.delete( |     response = api_client.post( | ||||||
|         api_routes.groups_shopping_lists_item_id_recipe_recipe_id(sample_list.id, recipe.id), headers=unique_user.token |         api_routes.groups_shopping_lists_item_id_recipe_recipe_id_delete(sample_list.id, recipe.id), | ||||||
|  |         headers=unique_user.token, | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     # Get List and Check for Ingredients |     # Get List and Check for Ingredients | ||||||
| @ -241,8 +242,9 @@ def test_shopping_lists_remove_recipe_multiple_quantity( | |||||||
|         assert item["note"] in known_ingredients |         assert item["note"] in known_ingredients | ||||||
| 
 | 
 | ||||||
|     # Remove Recipe |     # Remove Recipe | ||||||
|     response = api_client.delete( |     response = api_client.post( | ||||||
|         api_routes.groups_shopping_lists_item_id_recipe_recipe_id(sample_list.id, recipe.id), headers=unique_user.token |         api_routes.groups_shopping_lists_item_id_recipe_recipe_id_delete(sample_list.id, recipe.id), | ||||||
|  |         headers=unique_user.token, | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     # Get List and Check for Ingredients |     # Get List and Check for Ingredients | ||||||
| @ -271,7 +273,7 @@ def test_shopping_list_remove_recipe_scale( | |||||||
|     recipe = recipe_ingredient_only |     recipe = recipe_ingredient_only | ||||||
| 
 | 
 | ||||||
|     recipe_initital_scale = 100 |     recipe_initital_scale = 100 | ||||||
|     payload = {"recipeIncrementQuantity": recipe_initital_scale} |     payload: dict = {"recipeIncrementQuantity": recipe_initital_scale} | ||||||
| 
 | 
 | ||||||
|     # first add a bunch of quantity to the list |     # first add a bunch of quantity to the list | ||||||
|     response = api_client.post( |     response = api_client.post( | ||||||
| @ -299,8 +301,8 @@ def test_shopping_list_remove_recipe_scale( | |||||||
|     recipe_expected_scale = recipe_initital_scale - recipe_decrement_scale |     recipe_expected_scale = recipe_initital_scale - recipe_decrement_scale | ||||||
| 
 | 
 | ||||||
|     # remove some of the recipes |     # remove some of the recipes | ||||||
|     response = api_client.delete( |     response = api_client.post( | ||||||
|         api_routes.groups_shopping_lists_item_id_recipe_recipe_id(sample_list.id, recipe.id), |         api_routes.groups_shopping_lists_item_id_recipe_recipe_id_delete(sample_list.id, recipe.id), | ||||||
|         headers=unique_user.token, |         headers=unique_user.token, | ||||||
|         json=payload, |         json=payload, | ||||||
|     ) |     ) | ||||||
| @ -366,8 +368,8 @@ def test_recipe_decrement_max( | |||||||
| 
 | 
 | ||||||
|     # now remove way too many instances of the recipe |     # now remove way too many instances of the recipe | ||||||
|     payload = {"recipeDecrementQuantity": recipe_scale * 100} |     payload = {"recipeDecrementQuantity": recipe_scale * 100} | ||||||
|     response = api_client.delete( |     response = api_client.post( | ||||||
|         api_routes.groups_shopping_lists_item_id_recipe_recipe_id(sample_list.id, recipe.id), |         api_routes.groups_shopping_lists_item_id_recipe_recipe_id_delete(sample_list.id, recipe.id), | ||||||
|         headers=unique_user.token, |         headers=unique_user.token, | ||||||
|         json=payload, |         json=payload, | ||||||
|     ) |     ) | ||||||
|  | |||||||
| @ -279,6 +279,11 @@ def groups_shopping_lists_item_id_recipe_recipe_id(item_id, recipe_id): | |||||||
|     return f"{prefix}/groups/shopping/lists/{item_id}/recipe/{recipe_id}" |     return f"{prefix}/groups/shopping/lists/{item_id}/recipe/{recipe_id}" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def groups_shopping_lists_item_id_recipe_recipe_id_delete(item_id, recipe_id): | ||||||
|  |     """`/api/groups/shopping/lists/{item_id}/recipe/{recipe_id}/delete`""" | ||||||
|  |     return f"{prefix}/groups/shopping/lists/{item_id}/recipe/{recipe_id}/delete" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def groups_webhooks_item_id(item_id): | def groups_webhooks_item_id(item_id): | ||||||
|     """`/api/groups/webhooks/{item_id}`""" |     """`/api/groups/webhooks/{item_id}`""" | ||||||
|     return f"{prefix}/groups/webhooks/{item_id}" |     return f"{prefix}/groups/webhooks/{item_id}" | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| from requests import Response | from httpx import Response | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def assert_ignore_keys(dict1: dict, dict2: dict, ignore_keys: list = None) -> None: | def assert_ignore_keys(dict1: dict, dict2: dict, ignore_keys: list | None = None) -> None: | ||||||
|     """ |     """ | ||||||
|     Itterates through a list of keys and checks if they are in the the provided ignore_keys list, |     Itterates through a list of keys and checks if they are in the the provided ignore_keys list, | ||||||
|     if they are not in the ignore_keys list, it checks the value of the key in the provided against |     if they are not in the ignore_keys list, it checks the value of the key in the provided against | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user