diff --git a/tailbone/templates/custorders/create.mako b/tailbone/templates/custorders/create.mako index a78eed6c..cfbc4894 100644 --- a/tailbone/templates/custorders/create.mako +++ b/tailbone/templates/custorders/create.mako @@ -483,7 +483,8 @@ @click="showAddItemDialog()"> Add Item - Add Past Item @@ -1239,6 +1240,9 @@ type: 'is-danger', duration: 2000, // 2 seconds }) + if (failure) { + failure(response) + } }) }, @@ -1250,20 +1254,13 @@ } this.submitBatchData(params, response => { - if (response.data.error) { - this.$buefy.toast.open({ - message: "Submit failed: " + response.data.error, - type: 'is-danger', - duration: 2000, // 2 seconds - }) - this.submittingOrder = false + if (response.data.next_url) { + location.href = response.data.next_url } else { - if (response.data.next_url) { - location.href = response.data.next_url - } else { - location.reload() - } + location.reload() } + }, response => { + this.submittingOrder = false }) }, diff --git a/tailbone/views/custorders/orders.py b/tailbone/views/custorders/orders.py index 79753c50..49280d96 100644 --- a/tailbone/views/custorders/orders.py +++ b/tailbone/views/custorders/orders.py @@ -779,9 +779,13 @@ class CustomerOrderView(MasterView): 'batch': self.normalize_batch(batch)} def submit_new_order(self, batch, data): - result = self.execute_new_order_batch(batch, data) - if not result: - return {'error': "Batch failed to execute"} + try: + result = self.execute_new_order_batch(batch, data) + except Exception as error: + return {'error': six.text_type(error)} + else: + if not result: + return {'error': "Batch failed to execute"} next_url = None if isinstance(result, model.CustomerOrder):