diff --git a/registrasion/templatetags/registrasion_tags.py b/registrasion/templatetags/registrasion_tags.py index 6de13e74cf1fe7f95f557c3fadf2b033059fac30..63a2bc245d0a1fe70e525449e358a99b15e8eec7 100644 --- a/registrasion/templatetags/registrasion_tags.py +++ b/registrasion/templatetags/registrasion_tags.py @@ -35,14 +35,18 @@ def items_pending(context): @register.assignment_tag(takes_context=True) -def items_purchased(context): - ''' Returns all of the items that this user has purchased ''' +def items_purchased(context, category=None): + ''' Returns all of the items that this user has purchased, optionally + from the given category. ''' all_items = rego.ProductItem.objects.filter( cart__user=context.request.user, cart__active=False, ) + if category: + all_items = all_items.filter(product__category=category) + products = set(item.product for item in all_items) out = [] for product in products: