From f304fa27f910949ab6f1e13c2a2e64ab3c209e09 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sat, 28 May 2022 06:05:26 -0700 Subject: [PATCH] Fix empty invoice unhandled error --- api/logics.py | 9 +++++++-- api/views.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api/logics.py b/api/logics.py index 5f2cd31c..97c921ca 100644 --- a/api/logics.py +++ b/api/logics.py @@ -484,9 +484,14 @@ class Logics: @classmethod def update_invoice(cls, order, user, invoice): - + + # Empty invoice? + if not invoice: + return False, { + "bad_invoice": + "You submitted an empty invoice" + } # only the buyer can post a buyer invoice - if not cls.is_buyer(order, user): return False, { "bad_request": diff --git a/api/views.py b/api/views.py index 45795f8b..3b49a2ab 100644 --- a/api/views.py +++ b/api/views.py @@ -459,7 +459,7 @@ class OrderView(viewsets.ViewSet): ) # 2) If action is 'update invoice' - if action == "update_invoice" and invoice: + if action == "update_invoice": valid, context = Logics.update_invoice(order, request.user, invoice) if not valid: