def available_categories(context): ''' Gets all of the currently available products. Returns: [models.inventory.Category, ...]: A list of all of the categories that have Products that the current user can reserve. ''' return CategoryController.available_categories(context.request.user)
def test_available_categories(self): self.add_product_flag_on_category( condition=conditions.FlagBase.ENABLE_IF_TRUE, ) cart_1 = TestingCartController.for_user(self.USER_1) cats = CategoryController.available_categories( self.USER_1, ) self.assertFalse(self.CAT_1 in cats) self.assertTrue(self.CAT_2 in cats) cart_1.add_to_cart(self.PROD_3, 1) cats = CategoryController.available_categories( self.USER_1, ) self.assertTrue(self.CAT_1 in cats) self.assertTrue(self.CAT_2 in cats)
def available_categories(context): ''' Returns all of the available product categories ''' return CategoryController.available_categories(context.request.user)