geethareddy commited on
Commit
968eefe
·
verified ·
1 Parent(s): bf4234a

Update menu.py

Browse files
Files changed (1) hide show
  1. menu.py +15 -13
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. item_name.mp4 2. Video1__c from Salesforce 3. placeholder.mp4
25
  """
26
- # First try: item_name.mp4 in static folder
27
- video_file = f"{item_name.lower().replace(' ', '_')}.mp4"
28
- video_path = os.path.join(STATIC_DIR, video_file)
29
-
30
- if os.path.exists(video_path):
31
- return f"/static/{video_file}"
32
-
33
- # Second try: Video1__c from Salesforce if provided
34
- if video_url and video_url.startswith('/static/') and os.path.exists(os.path.join(STATIC_DIR, video_url[8:])):
35
- return video_url
 
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
- # Query menu items (without Video1__c since it's not available)
75
  menu_query = """
76
- SELECT Name, Price__c, Description__c, Image1__c, Image2__c, Veg_NonVeg__c, Section__c, Total_Ordered__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)