Spaces:
Sleeping
Sleeping
Update menu.py
Browse files
menu.py
CHANGED
|
@@ -21,18 +21,19 @@ if not os.path.exists(PLACEHOLDER_PATH):
|
|
| 21 |
def get_valid_video_path(item_name, video_url=None):
|
| 22 |
"""
|
| 23 |
Get valid video path for item with placeholder fallback
|
| 24 |
-
Priority: 1.
|
| 25 |
"""
|
| 26 |
-
# First try:
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
# Final fallback: placeholder.mp4
|
| 38 |
if not os.path.exists(PLACEHOLDER_PATH):
|
|
@@ -71,9 +72,10 @@ def menu():
|
|
| 71 |
referral_code = user_result['records'][0].get('Referral__c', 'N/A')
|
| 72 |
reward_points = user_result['records'][0].get('Reward_Points__c', 0)
|
| 73 |
|
| 74 |
-
|
| 75 |
menu_query = """
|
| 76 |
-
SELECT Name, Price__c, Description__c, Image1__c, Image2__c,
|
|
|
|
| 77 |
FROM Menu_Item__c
|
| 78 |
"""
|
| 79 |
result = sf.query(menu_query)
|
|
|
|
| 21 |
def get_valid_video_path(item_name, video_url=None):
|
| 22 |
"""
|
| 23 |
Get valid video path for item with placeholder fallback
|
| 24 |
+
Priority: 1. Video1__c from Salesforce 2. placeholder.mp4
|
| 25 |
"""
|
| 26 |
+
# First try: Video1__c from Salesforce if provided
|
| 27 |
+
if video_url:
|
| 28 |
+
# If it's a complete URL (http/https)
|
| 29 |
+
if video_url.startswith(('http://', 'https://')):
|
| 30 |
+
return video_url
|
| 31 |
+
# If it's a relative path (/videos/xxx.mp4)
|
| 32 |
+
elif video_url.startswith('/'):
|
| 33 |
+
return video_url
|
| 34 |
+
# If it's a Salesforce File ID (starts with '069')
|
| 35 |
+
elif video_url.startswith('069'):
|
| 36 |
+
return f"https://yourdomain.my.salesforce.com/sfc/servlet.shepherd/version/download/{video_url}"
|
| 37 |
|
| 38 |
# Final fallback: placeholder.mp4
|
| 39 |
if not os.path.exists(PLACEHOLDER_PATH):
|
|
|
|
| 72 |
referral_code = user_result['records'][0].get('Referral__c', 'N/A')
|
| 73 |
reward_points = user_result['records'][0].get('Reward_Points__c', 0)
|
| 74 |
|
| 75 |
+
# Query to fetch Menu_Item__c records including Video1__c
|
| 76 |
menu_query = """
|
| 77 |
+
SELECT Name, Price__c, Description__c, Image1__c, Image2__c,
|
| 78 |
+
Veg_NonVeg__c, Section__c, Total_Ordered__c, Video1__c
|
| 79 |
FROM Menu_Item__c
|
| 80 |
"""
|
| 81 |
result = sf.query(menu_query)
|