From c9a62db774c57ec5b2b057787aedb84a401a1813 2016-04-06 07:02:11 From: Christopher Neugebauer Date: 2016-04-06 07:02:11 Subject: [PATCH] Resolves #17 - cannot generate invoice if there are no product items --- diff --git a/registrasion/controllers/invoice.py b/registrasion/controllers/invoice.py index fdea324bfd3ac14ac000ff8c5265e5212512a917..dafb134b9dd8fc6cdf39bde6770d11b00615e6a2 100644 --- a/registrasion/controllers/invoice.py +++ b/registrasion/controllers/invoice.py @@ -67,8 +67,11 @@ class InvoiceController(object): ) invoice.save() - # TODO: calculate line items. product_items = rego.ProductItem.objects.filter(cart=cart) + + if len(product_items) == 0: + raise ValidationError("Your cart is empty.") + product_items = product_items.order_by( "product__category__order", "product__order" )