nagasurendra commited on
Commit
46a4f8b
·
verified ·
1 Parent(s): 109dc1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -22
app.py CHANGED
@@ -143,38 +143,39 @@ def submit_customization_ingredients():
143
 
144
  try:
145
  if items: # Cart submission
146
- ingredient_name = f"Order_{datetime.now().strftime('%Y%m%d')}_{uuid.uuid4().hex[:8]}"
147
  for item in items:
148
- description = f"{item['name']} ({item.get('instructions', 'No instructions')})"
149
- if item.get('ingredients'):
150
- description += f", Ingredients: {', '.join(i['name'] for i in item['ingredients'])}"
151
- sf.Ingredient_Object__c.create({
152
- 'Ingredient_Name__c': ingredient_name,
153
- 'Category__c': item.get('veg_nonveg', ''),
154
- 'Description__c': description,
155
- 'Image_URL__c': item.get('image_url', ''),
156
  'Quantity__c': 1,
157
- 'Ingredientsinfo__c': item.get('instructions', '')
 
 
 
 
158
  })
159
- logger.debug(f"Submitted {len(items)} items under {ingredient_name}")
160
  return jsonify({"success": True, "message": f"Submitted {len(items)} items"})
 
161
  elif menu_item: # Single item customization
162
- ingredient_name = f"Custom_{menu_item['name']}_{uuid.uuid4().hex[:8]}"
163
- description = f"{menu_item['name']} ({instructions or 'No instructions'})"
164
- if ingredients:
165
- description += f", Ingredients: {', '.join(i['name'] for i in ingredients)}"
166
- sf.Ingredient_Object__c.create({
167
- 'Ingredient_Name__c': ingredient_name,
168
- 'Category__c': menu_item.get('veg_nonveg', ''),
169
- 'Description__c': description,
170
- 'Image_URL__c': menu_item.get('image_url', ''),
171
  'Quantity__c': 1,
172
- 'Ingredientsinfo__c': instructions
 
 
 
 
173
  })
174
- logger.debug(f"Submitted customization for {menu_item['name']}")
175
  return jsonify({"success": True, "message": "Customization submitted"})
 
176
  else:
177
  return jsonify({"error": "No items or menu item provided"}), 400
 
178
  except Exception as e:
179
  logger.error(f"Failed to submit: {str(e)}")
180
  return jsonify({"error": f"Failed to submit: {str(e)}"}), 500
 
143
 
144
  try:
145
  if items: # Cart submission
 
146
  for item in items:
147
+ ingredient_names = ', '.join(i['name'] for i in item.get('ingredients', [])) if item.get('ingredients') else ''
148
+ sf.Cart_Item__c.create({
149
+ 'Name': item['name'],
150
+ 'Base_Price__c': item.get('price', 0.0),
 
 
 
 
151
  'Quantity__c': 1,
152
+ 'Add_Ons__c': ingredient_names,
153
+ 'Add_Ons_Price__c': 0,
154
+ 'Image1__c': item.get('image_url', ''),
155
+
156
+ 'Instructions__c': item.get('instructions', '')
157
  })
158
+ logger.debug(f"Submitted {len(items)} items to Cart_Item__c")
159
  return jsonify({"success": True, "message": f"Submitted {len(items)} items"})
160
+
161
  elif menu_item: # Single item customization
162
+ ingredient_names = ', '.join(i['name'] for i in ingredients) if ingredients else ''
163
+ sf.Cart_Item__c.create({
164
+ 'Name': menu_item['name'],
165
+ 'Base_Price__c': menu_item.get('price', 0.0),
 
 
 
 
 
166
  'Quantity__c': 1,
167
+ 'Add_Ons__c': ingredient_names,
168
+ 'Add_Ons_Price__c': 0,
169
+ 'Image1__c': menu_item.get('image_url', ''),
170
+
171
+ 'Instructions__c': instructions
172
  })
173
+ logger.debug(f"Submitted customization for {menu_item['name']} to Cart_Item__c")
174
  return jsonify({"success": True, "message": "Customization submitted"})
175
+
176
  else:
177
  return jsonify({"error": "No items or menu item provided"}), 400
178
+
179
  except Exception as e:
180
  logger.error(f"Failed to submit: {str(e)}")
181
  return jsonify({"error": f"Failed to submit: {str(e)}"}), 500