示例#1
0
    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)
示例#2
0
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(user_for_context(context))
示例#3
0
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)
示例#4
0
def missing_categories(context):
    ''' Adds the categories that the user does not currently have. '''
    user = user_for_context(context)
    categories_available = set(CategoryController.available_categories(user))
    items = ItemController(user).items_pending_or_purchased()

    categories_held = set()

    for product, quantity in items:
        categories_held.add(product.category)

    return categories_available - categories_held
示例#5
0
    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)
示例#6
0
def available_categories(context):
    ''' Returns all of the available product categories '''
    return CategoryController.available_categories(context.request.user)