Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,6 +65,7 @@ def generate_coupon_code(length=10):
|
|
| 65 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 66 |
|
| 67 |
|
|
|
|
| 68 |
@app.route("/generate_custom_dish", methods=["POST"])
|
| 69 |
def generate_custom_dish():
|
| 70 |
try:
|
|
@@ -99,7 +100,28 @@ def generate_custom_dish():
|
|
| 99 |
result = sf.Custom_Dish__c.create(custom_dish)
|
| 100 |
|
| 101 |
if result.get('success'):
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
else:
|
| 104 |
return jsonify({"success": False, "error": "Failed to create custom dish in Salesforce"}), 500
|
| 105 |
|
|
@@ -107,6 +129,7 @@ def generate_custom_dish():
|
|
| 107 |
return jsonify({"success": False, "error": str(e)}), 500
|
| 108 |
|
| 109 |
|
|
|
|
| 110 |
import re
|
| 111 |
@app.route("/edit_profile", methods=["GET", "POST"])
|
| 112 |
def edit_profile():
|
|
|
|
| 65 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 66 |
|
| 67 |
|
| 68 |
+
|
| 69 |
@app.route("/generate_custom_dish", methods=["POST"])
|
| 70 |
def generate_custom_dish():
|
| 71 |
try:
|
|
|
|
| 100 |
result = sf.Custom_Dish__c.create(custom_dish)
|
| 101 |
|
| 102 |
if result.get('success'):
|
| 103 |
+
# After creating the custom dish, add it to the Cart_Item__c
|
| 104 |
+
email = session.get('user_email') # Assuming you have the user's email in session
|
| 105 |
+
|
| 106 |
+
# Create the cart item with custom dish details and set other fields to default values
|
| 107 |
+
cart_item = {
|
| 108 |
+
'Name': dish_name,
|
| 109 |
+
'Price__c': price,
|
| 110 |
+
'Quantity__c': 1, # Assuming a default quantity of 1 for the custom dish
|
| 111 |
+
'Add_Ons__c': '', # Set Add_ons__c to empty
|
| 112 |
+
'Add_Ons_Price__c': 0, # Set Add_Ons_Price__c to 0
|
| 113 |
+
'Instructions__c': '', # Use the custom dish description as the instructions
|
| 114 |
+
'Customer_Email__c': email # Associate the custom dish with the logged-in user
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
# Insert the custom dish as a Cart_Item__c record in Salesforce
|
| 118 |
+
cart_result = sf.Cart_Item__c.create(cart_item)
|
| 119 |
+
|
| 120 |
+
if cart_result.get('success'):
|
| 121 |
+
return redirect(url_for("cart")) # Redirect to the cart page after adding to the cart
|
| 122 |
+
else:
|
| 123 |
+
return jsonify({"success": False, "error": "Failed to add custom dish to the cart"}), 500
|
| 124 |
+
|
| 125 |
else:
|
| 126 |
return jsonify({"success": False, "error": "Failed to create custom dish in Salesforce"}), 500
|
| 127 |
|
|
|
|
| 129 |
return jsonify({"success": False, "error": str(e)}), 500
|
| 130 |
|
| 131 |
|
| 132 |
+
|
| 133 |
import re
|
| 134 |
@app.route("/edit_profile", methods=["GET", "POST"])
|
| 135 |
def edit_profile():
|