From e723ec937b4e9d69686b0a0e5827d698b89bcfcb Mon Sep 17 00:00:00 2001 From: James Polley Date: Mon, 21 Jan 2019 10:43:47 +1300 Subject: [PATCH] Add debug logging for product availability checks --- .../registrasion/registrasion/controllers/product.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vendor/registrasion/registrasion/controllers/product.py b/vendor/registrasion/registrasion/controllers/product.py index 4210bd7c..c2ef7d26 100644 --- a/vendor/registrasion/registrasion/controllers/product.py +++ b/vendor/registrasion/registrasion/controllers/product.py @@ -1,4 +1,5 @@ import itertools +import logging from django.db.models import Case from django.db.models import F, Q @@ -23,6 +24,9 @@ class ProductController(object): def available_products(cls, user, category=None, products=None): ''' Returns a list of all of the products that are available per flag conditions from the given categories. ''' + logging.debug("Checking available products for user %(user)s: " + "category %(category)s or products %(product)s", + {'user': user, 'category': category, 'products': products}) if category is None and products is None: raise ValueError("You must provide products or a category") @@ -45,14 +49,20 @@ class ProductController(object): if product_remainders[product.id] > 0 ) + logging.debug("Passed limits: %s", passed_limits) + failed_and_messages = FlagController.test_flags( user, products=passed_limits ) failed_conditions = set(i[0] for i in failed_and_messages) + logging.debug("Failed conditions: %s", failed_conditions) + out = list(passed_limits - failed_conditions) out.sort(key=lambda product: product.order) + logging.debug("Returning: %s", out) + return out @classmethod