lokesh341 commited on
Commit
d8f44d1
·
verified ·
1 Parent(s): 3c14339

Update menu.py

Browse files
Files changed (1) hide show
  1. menu.py +18 -2
menu.py CHANGED
@@ -1,6 +1,7 @@
1
  from flask import Blueprint, render_template, request, session, jsonify, redirect, url_for
2
  from salesforce import get_salesforce_connection
3
  import os
 
4
  import logging
5
  from urllib.parse import quote
6
  from datetime import datetime, timedelta
@@ -15,7 +16,7 @@ menu_blueprint = Blueprint('menu', __name__)
15
  sf = get_salesforce_connection()
16
 
17
  # Constants
18
- STATIC_DIR = os.path.join(os.path.dirname(__file__), 'static')
19
  PLACEHOLDER_VIDEO = 'placeholder.mp4'
20
  PLACEHOLDER_IMAGE = 'placeholder.jpg'
21
  PLACEHOLDER_VIDEO_PATH = os.path.join(STATIC_DIR, PLACEHOLDER_VIDEO)
@@ -25,8 +26,23 @@ SECTION_ORDER = ["Best Sellers", "Starters", "Biryanis", "Curries", "Breads",
25
  MAX_BEST_SELLERS = 4
26
  DEFAULT_VIDEO_URL = "https://yourdomain.my.salesforce.com/sfc/servlet.shepherd/version/download/"
27
 
28
- # Create placeholder files if they don't exist
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  def initialize_placeholders():
 
30
  try:
31
  if not os.path.exists(PLACEHOLDER_VIDEO_PATH):
32
  with open(PLACEHOLDER_VIDEO_PATH, 'wb') as f:
 
1
  from flask import Blueprint, render_template, request, session, jsonify, redirect, url_for
2
  from salesforce import get_salesforce_connection
3
  import os
4
+ import re
5
  import logging
6
  from urllib.parse import quote
7
  from datetime import datetime, timedelta
 
16
  sf = get_salesforce_connection()
17
 
18
  # Constants
19
+ STATIC_DIR = os.path.join(os.path.dirname(__file__), '..', 'static')
20
  PLACEHOLDER_VIDEO = 'placeholder.mp4'
21
  PLACEHOLDER_IMAGE = 'placeholder.jpg'
22
  PLACEHOLDER_VIDEO_PATH = os.path.join(STATIC_DIR, PLACEHOLDER_VIDEO)
 
26
  MAX_BEST_SELLERS = 4
27
  DEFAULT_VIDEO_URL = "https://yourdomain.my.salesforce.com/sfc/servlet.shepherd/version/download/"
28
 
29
+ # Custom Jinja2 filter
30
+ def slugify(text):
31
+ """Convert text to a slug format (lowercase, replace spaces with hyphens)"""
32
+ if not text:
33
+ return ""
34
+ text = text.lower()
35
+ text = re.sub(r'[^\w\s-]', '', text) # Remove non-alphanumeric chars
36
+ text = re.sub(r'[\s-]+', '-', text) # Replace spaces and multiple hyphens with single hyphen
37
+ return text
38
+
39
+ # Register the filter with the blueprint
40
+ @menu_blueprint.app_template_filter('slugify')
41
+ def slugify_filter(s):
42
+ return slugify(s)
43
+
44
  def initialize_placeholders():
45
+ """Create placeholder files if they don't exist"""
46
  try:
47
  if not os.path.exists(PLACEHOLDER_VIDEO_PATH):
48
  with open(PLACEHOLDER_VIDEO_PATH, 'wb') as f: