lokesh341 commited on
Commit
d885605
·
verified ·
1 Parent(s): a35e901

Update menu.py

Browse files
Files changed (1) hide show
  1. menu.py +13 -13
menu.py CHANGED
@@ -67,11 +67,10 @@ def menu():
67
  cart_count_result = sf.query(cart_query)
68
  cart_item_count = cart_count_result.get('totalSize', 0)
69
 
70
- # Fetch all Menu_Item__c records with all required fields
71
  menu_query = """
72
  SELECT Name, Price__c, Description__c, Image1__c, Image2__c,
73
- Veg_NonVeg__c, Section__c, Total_Ordered__c, Video1__c,
74
- IngredientsInfo__c, NutritionalInfo__c, Allergens__c
75
  FROM Menu_Item__c
76
  """
77
  menu_result = sf.query_all(menu_query)
@@ -83,15 +82,15 @@ def menu():
83
  item['Video1__c'] = get_valid_video_path(item['Name'], item.get('Video1__c'))
84
  item['Section__c'] = item.get('Section__c', "Others")
85
  item['Description__c'] = item.get('Description__c', "No description available")
86
- item['IngredientsInfo__c'] = item.get('IngredientsInfo__c', "Not specified")
87
- item['NutritionalInfo__c'] = item.get('NutritionalInfo__c', "Not available")
88
- item['Allergens__c'] = item.get('Allergens__c', "None listed")
 
89
 
90
- # Fetch all Custom_Dish__c records with all required fields
91
  custom_dish_query = """
92
  SELECT Name, Price__c, Description__c, Image1__c, Image2__c,
93
- Veg_NonVeg__c, Section__c, Total_Ordered__c,
94
- IngredientsInfo__c, NutritionalInfo__c, Allergens__c
95
  FROM Custom_Dish__c
96
  WHERE CreatedDate >= LAST_N_DAYS:7
97
  """
@@ -104,9 +103,10 @@ def menu():
104
  item['Video1__c'] = get_valid_video_path(item['Name'])
105
  item['Section__c'] = item.get('Section__c', "Customized dish")
106
  item['Description__c'] = item.get('Description__c', "No description available")
107
- item['IngredientsInfo__c'] = item.get('IngredientsInfo__c', "Not specified")
108
- item['NutritionalInfo__c'] = item.get('NutritionalInfo__c', "Not available")
109
- item['Allergens__c'] = item.get('Allergens__c', "None listed")
 
110
 
111
  # Merge all items
112
  all_items = food_items + custom_dishes
@@ -208,7 +208,7 @@ def add_to_cart():
208
  quantity = int(data.get('quantity', 1))
209
  customer_email = session.get('user_email')
210
 
211
- if not item_name or not item_price or not customer_email:
212
  return jsonify({"success": False, "error": "Item name, price, and user email are required."}), 400
213
 
214
  query = f"""
 
67
  cart_count_result = sf.query(cart_query)
68
  cart_item_count = cart_count_result.get('totalSize', 0)
69
 
70
+ # Fetch all Menu_Item__c records with only existing fields
71
  menu_query = """
72
  SELECT Name, Price__c, Description__c, Image1__c, Image2__c,
73
+ Veg_NonVeg__c, Section__c, Total_Ordered__c, Video1__c
 
74
  FROM Menu_Item__c
75
  """
76
  menu_result = sf.query_all(menu_query)
 
82
  item['Video1__c'] = get_valid_video_path(item['Name'], item.get('Video1__c'))
83
  item['Section__c'] = item.get('Section__c', "Others")
84
  item['Description__c'] = item.get('Description__c', "No description available")
85
+ # Add default values for missing fields
86
+ item['IngredientsInfo__c'] = "Not specified"
87
+ item['NutritionalInfo__c'] = "Not available"
88
+ item['Allergens__c'] = "None listed"
89
 
90
+ # Fetch all Custom_Dish__c records with only existing fields
91
  custom_dish_query = """
92
  SELECT Name, Price__c, Description__c, Image1__c, Image2__c,
93
+ Veg_NonVeg__c, Section__c, Total_Ordered__c
 
94
  FROM Custom_Dish__c
95
  WHERE CreatedDate >= LAST_N_DAYS:7
96
  """
 
103
  item['Video1__c'] = get_valid_video_path(item['Name'])
104
  item['Section__c'] = item.get('Section__c', "Customized dish")
105
  item['Description__c'] = item.get('Description__c', "No description available")
106
+ # Add default values for missing fields
107
+ item['IngredientsInfo__c'] = "Not specified"
108
+ item['NutritionalInfo__c'] = "Not available"
109
+ item['Allergens__c'] = "None listed"
110
 
111
  # Merge all items
112
  all_items = food_items + custom_dishes
 
208
  quantity = int(data.get('quantity', 1))
209
  customer_email = session.get('user_email')
210
 
211
+ if not item_name or not item_price or not customer_emailKILL
212
  return jsonify({"success": False, "error": "Item name, price, and user email are required."}), 400
213
 
214
  query = f"""