diff options
-rw-r--r-- | alphabetlearning/resources/views.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/alphabetlearning/resources/views.py b/alphabetlearning/resources/views.py index c09ff78..0aae929 100644 --- a/alphabetlearning/resources/views.py +++ b/alphabetlearning/resources/views.py @@ -322,10 +322,12 @@ def resource_detail(request, resource_id): "created": resource_metadata.created, "updated": resource_metadata.updated, } - # TODO test for this existing - it will fail if no cart - cart_items = request.user.shoppingcart.items.all() - if resource["name"] in [r.resource.name for r in cart_items]: - resource.update(in_cart=True) + try: + cart_items = request.user.shoppingcart.items.all() + if resource["name"] in [r.resource.name for r in cart_items]: + resource.update(in_cart=True) + except: + pass return render(request, "resources/resource_detail.html", {"resource": resource}) |