def recipe_store(data): """ """ recipe_name = data.get("recipe_name") if not recipe_name: return {"success": False, "message": "Please provide the recipe name"} ingredients = data.get("ingredients_details") if not ingredients: return {"success": False, "message": "Please provide the ingredients"} if Recipe.objects(name=recipe_name).first(): rcp = Recipe.objects(name=recipe_name).first() else: rcp = Recipe(name=recipe_name) pfcf_value = calculate_pfcf_value(ingredients) if not pfcf_value["success"]: return pfcf_value rcp.ingredients = pfcf_value["data"]["ingredient"] rcp.protein = pfcf_value["data"]["protein"] rcp.carbs = pfcf_value["data"]["carbs"] rcp.fat = pfcf_value["data"]["fat"] rcp.F = pfcf_value["data"]["F"] rcp.save() return {"success": True, "message": "recipe stored successfully"}