Update app.py
Browse files
app.py
CHANGED
|
@@ -48,6 +48,21 @@ def generate_coupon_code(length=10):
|
|
| 48 |
"""Generates a random alphanumeric coupon code"""
|
| 49 |
characters = string.ascii_uppercase + string.digits # A-Z, 0-9
|
| 50 |
return ''.join(random.choice(characters) for _ in range(length))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
@app.route("/signup", methods=["GET", "POST"])
|
| 53 |
def signup():
|
|
|
|
| 48 |
"""Generates a random alphanumeric coupon code"""
|
| 49 |
characters = string.ascii_uppercase + string.digits # A-Z, 0-9
|
| 50 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 51 |
+
@app.route('/previous-orders')
|
| 52 |
+
def previous_orders():
|
| 53 |
+
user_email = request.cookies.get('email') # Or get email from session/authentication
|
| 54 |
+
sf = SalesforceConnection()
|
| 55 |
+
|
| 56 |
+
# Query to fetch all orders based on email
|
| 57 |
+
query = f"""
|
| 58 |
+
SELECT Order_Number__c, Order_Details__c
|
| 59 |
+
FROM Order__c
|
| 60 |
+
WHERE Customer_Email__c = '{user_email}'
|
| 61 |
+
ORDER BY CreatedDate DESC
|
| 62 |
+
"""
|
| 63 |
+
orders = sf.query(query)
|
| 64 |
+
|
| 65 |
+
return render_template('previous_orders.html', previous_orders=orders['records'])
|
| 66 |
|
| 67 |
@app.route("/signup", methods=["GET", "POST"])
|
| 68 |
def signup():
|