Update menu.py
Browse files
menu.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from flask import Blueprint, render_template, request, session, jsonify, redirect, url_for
|
2 |
from salesforce import get_salesforce_connection
|
3 |
import os
|
@@ -77,9 +78,9 @@ def menu():
|
|
77 |
cart_count_result = sf.query(cart_query)
|
78 |
cart_item_count = cart_count_result['totalSize']
|
79 |
|
80 |
-
# Query to fetch Menu_Item__c records including
|
81 |
menu_query = """
|
82 |
-
SELECT Name, Price__c, Description__c,
|
83 |
Veg_NonVeg__c, Section__c, Total_Ordered__c, Video1__c
|
84 |
FROM Menu_Item__c
|
85 |
"""
|
@@ -91,13 +92,10 @@ def menu():
|
|
91 |
if 'Total_Ordered__c' not in item or item['Total_Ordered__c'] is None:
|
92 |
item['Total_Ordered__c'] = 0
|
93 |
item['Video1__c'] = get_valid_video_path(item['Name'], item.get('Video1__c'))
|
94 |
-
# Set default values for Ingredients__c and Description__c if null
|
95 |
-
item['Ingredients__c'] = item.get('Ingredients__c', 'Not specified')
|
96 |
-
item['Description__c'] = item.get('Description__c', 'No description available')
|
97 |
|
98 |
-
# Query to fetch Custom_Dish__c records
|
99 |
custom_dish_query = """
|
100 |
-
SELECT Name, Price__c, Description__c,
|
101 |
Veg_NonVeg__c, Section__c, Total_Ordered__c
|
102 |
FROM Custom_Dish__c
|
103 |
WHERE CreatedDate >= LAST_N_DAYS:7
|
@@ -110,9 +108,6 @@ def menu():
|
|
110 |
if 'Total_Ordered__c' not in item or item['Total_Ordered__c'] is None:
|
111 |
item['Total_Ordered__c'] = 0
|
112 |
item['Video1__c'] = get_valid_video_path(item['Name'])
|
113 |
-
# Set default values for Ingredients__c and Description__c if null
|
114 |
-
item['Ingredients__c'] = item.get('Ingredients__c', 'Not specified')
|
115 |
-
item['Description__c'] = item.get('Description__c', 'No description available')
|
116 |
|
117 |
# Merge both Menu_Item__c and Custom_Dish__c records
|
118 |
all_items = food_items + custom_dishes
|
@@ -153,14 +148,13 @@ def menu():
|
|
153 |
|
154 |
except Exception as e:
|
155 |
print(f"Error fetching menu data: {str(e)}")
|
156 |
-
# Fallback data with video support
|
157 |
ordered_menu = {section: [] for section in SECTION_ORDER}
|
158 |
best_sellers = ["Chicken Biryani", "Paneer Butter Masala", "Veg Manchurian", "Prawn Fry"]
|
159 |
ordered_menu["Best Sellers"] = [{
|
160 |
"Name": name,
|
161 |
"Price__c": "12.99",
|
162 |
"Description__c": f"Popular {name}",
|
163 |
-
"Ingredients__c": "Not specified",
|
164 |
"Image1__c": "/static/placeholder.jpg",
|
165 |
"Video1__c": get_valid_video_path(name),
|
166 |
"Total_Ordered__c": 100,
|
@@ -315,4 +309,4 @@ def add_to_cart():
|
|
315 |
|
316 |
except Exception as e:
|
317 |
print(f"Error adding item to cart: {str(e)}")
|
318 |
-
return jsonify({"success": False, "error": "An error occurred while adding the item to the cart."}), 500
|
|
|
1 |
+
|
2 |
from flask import Blueprint, render_template, request, session, jsonify, redirect, url_for
|
3 |
from salesforce import get_salesforce_connection
|
4 |
import os
|
|
|
78 |
cart_count_result = sf.query(cart_query)
|
79 |
cart_item_count = cart_count_result['totalSize']
|
80 |
|
81 |
+
# Query to fetch Menu_Item__c records including Video1__c
|
82 |
menu_query = """
|
83 |
+
SELECT Name, Price__c, Description__c, Image1__c, Image2__c,
|
84 |
Veg_NonVeg__c, Section__c, Total_Ordered__c, Video1__c
|
85 |
FROM Menu_Item__c
|
86 |
"""
|
|
|
92 |
if 'Total_Ordered__c' not in item or item['Total_Ordered__c'] is None:
|
93 |
item['Total_Ordered__c'] = 0
|
94 |
item['Video1__c'] = get_valid_video_path(item['Name'], item.get('Video1__c'))
|
|
|
|
|
|
|
95 |
|
96 |
+
# Query to fetch Custom_Dish__c records
|
97 |
custom_dish_query = """
|
98 |
+
SELECT Name, Price__c, Description__c, Image1__c, Image2__c,
|
99 |
Veg_NonVeg__c, Section__c, Total_Ordered__c
|
100 |
FROM Custom_Dish__c
|
101 |
WHERE CreatedDate >= LAST_N_DAYS:7
|
|
|
108 |
if 'Total_Ordered__c' not in item or item['Total_Ordered__c'] is None:
|
109 |
item['Total_Ordered__c'] = 0
|
110 |
item['Video1__c'] = get_valid_video_path(item['Name'])
|
|
|
|
|
|
|
111 |
|
112 |
# Merge both Menu_Item__c and Custom_Dish__c records
|
113 |
all_items = food_items + custom_dishes
|
|
|
148 |
|
149 |
except Exception as e:
|
150 |
print(f"Error fetching menu data: {str(e)}")
|
151 |
+
# Fallback data with video support
|
152 |
ordered_menu = {section: [] for section in SECTION_ORDER}
|
153 |
best_sellers = ["Chicken Biryani", "Paneer Butter Masala", "Veg Manchurian", "Prawn Fry"]
|
154 |
ordered_menu["Best Sellers"] = [{
|
155 |
"Name": name,
|
156 |
"Price__c": "12.99",
|
157 |
"Description__c": f"Popular {name}",
|
|
|
158 |
"Image1__c": "/static/placeholder.jpg",
|
159 |
"Video1__c": get_valid_video_path(name),
|
160 |
"Total_Ordered__c": 100,
|
|
|
309 |
|
310 |
except Exception as e:
|
311 |
print(f"Error adding item to cart: {str(e)}")
|
312 |
+
return jsonify({"success": False, "error": "An error occurred while adding the item to the cart."}), 500
|