From e308108bf761ab446c552255e5e175a640ae4f42 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 24 Oct 2023 17:48:08 -0500 Subject: [PATCH] Show user warning if "add item to custorder" fails specifically, if user enters alpha chars for cost/price fields --- tailbone/templates/custorders/create.mako | 2 ++ tailbone/views/custorders/orders.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tailbone/templates/custorders/create.mako b/tailbone/templates/custorders/create.mako index 663c4300..7d3b367f 100644 --- a/tailbone/templates/custorders/create.mako +++ b/tailbone/templates/custorders/create.mako @@ -2124,6 +2124,8 @@ this.itemDialogSaving = false this.showingItemDialog = false + }, response => { + this.itemDialogSaving = false }) }, }, diff --git a/tailbone/views/custorders/orders.py b/tailbone/views/custorders/orders.py index f88886bb..60949e8f 100644 --- a/tailbone/views/custorders/orders.py +++ b/tailbone/views/custorders/orders.py @@ -864,7 +864,10 @@ class CustomerOrderView(MasterView): for field in ('unit_cost', 'regular_price_amount', 'case_size'): if field in pending_info: - pending_info[field] = decimal.Decimal(pending_info[field]) + try: + pending_info[field] = decimal.Decimal(pending_info[field]) + except decimal.InvalidOperation: + return {'error': f"Invalid entry for field: {field}"} pending_info['user'] = self.request.user