def testGetAmountOfProducts_1(self): """As manager """ pm = IProductManagement(self.shop.groups.group_1) self.assertEqual(len(pm.getProducts()), 2) pm = IProductManagement(self.shop.groups.group_2) self.assertEqual(len(pm.getProducts()), 1)
def testGetAmountOfProducts_1(self): """As manager """ pm = IProductManagement(self.shop.groups.group_1) self.assertEqual(len(pm.getProducts()), 2) pm = IProductManagement(self.shop.groups.group_2) self.assertEqual(len(pm.getProducts()), 1)
def testGetAmountOfProducts_2(self): """As anonymous. Note that only products are counted for which the user has the View permission. """ self.logout() pm = IProductManagement(self.shop.groups.group_1) self.assertEqual(len(pm.getProducts()), 0) pm = IProductManagement(self.shop.groups.group_2) self.assertEqual(len(pm.getProducts()), 0)
def testGetProducts_1(self): """As manager """ pm = IProductManagement(self.shop.groups.group_1) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, ["product_1", "product_2"]) pm = IProductManagement(self.shop.groups.group_2) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, ["product_1"])
def testGetAmountOfProducts_2(self): """As anonymous. Note that only products are counted for which the user has the View permission. """ self.logout() pm = IProductManagement(self.shop.groups.group_1) self.assertEqual(len(pm.getProducts()), 0) pm = IProductManagement(self.shop.groups.group_2) self.assertEqual(len(pm.getProducts()), 0)
def testGetProducts_1(self): """As manager """ pm = IProductManagement(self.shop.groups.group_1) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, ["product_1", "product_2"]) pm = IProductManagement(self.shop.groups.group_2) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, ["product_1"])
def testGetProducts(self): """ """ pm = IProductManagement(self.portal.myshop.categories.category_1) self.assertEqual(pm.getProducts(), []) pm = IProductManagement(self.portal.myshop.categories.category_2) self.assertEqual(pm.getProducts(), []) pm = IProductManagement(self.portal.myshop.categories.category_1.category_11) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, ["product_1", "product_2"])
def testGetProducts(self): """ """ pm = IProductManagement(self.portal.myshop.categories.category_1) self.assertEqual(pm.getProducts(), []) pm = IProductManagement(self.portal.myshop.categories.category_2) self.assertEqual(pm.getProducts(), []) pm = IProductManagement( self.portal.myshop.categories.category_1.category_11) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, ["product_1", "product_2"])
def testGetProducts_2(self): """As anonymous. Note hat only products return for which the user has the View permission. """ self.logout() pm = IProductManagement(self.shop.groups.group_1) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, []) pm = IProductManagement(self.shop.groups.group_2) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, [])
def testGetAmountOfProducts_3(self): """As anonymous, with product_2 published. """ wftool = getToolByName(self.shop, "portal_workflow") wftool.doActionFor(self.product_2, "publish") self.logout() pm = IProductManagement(self.shop.groups.group_1) self.assertEqual(len(pm.getProducts()), 1) pm = IProductManagement(self.shop.groups.group_2) self.assertEqual(len(pm.getProducts()), 0)
def testGetProducts_2(self): """As anonymous. Note hat only products return for which the user has the View permission. """ self.logout() pm = IProductManagement(self.shop.groups.group_1) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, []) pm = IProductManagement(self.shop.groups.group_2) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, [])
def testGetAmountOfProducts_3(self): """As anonymous, with product_2 published. """ wftool = getToolByName(self.shop, "portal_workflow") wftool.doActionFor(self.product_2, "publish") self.logout() pm = IProductManagement(self.shop.groups.group_1) self.assertEqual(len(pm.getProducts()), 1) pm = IProductManagement(self.shop.groups.group_2) self.assertEqual(len(pm.getProducts()), 0)
def getProducts(self): """ """ shop = IShopManagement(self.context).getShop() pm = IProductManagement(shop) result = [] for product in pm.getProducts(): result.append({ "uid": product.UID, "title": product.Title, }) # Get start page b_start = self.request.get('b_start', 0) if b_start == "None": b_start = 0 batch = Batch(result, 20, int(b_start), orphan=0) # Calculate Batch return { "batch": batch, "next_url": self._getNextUrl(batch), "previous_url": self._getPreviousUrl(batch) }
def getProducts(self): """ """ shop = IShopManagement(self.context).getShop() pm = IProductManagement(shop) result = [] for product in pm.getProducts(): result.append({ "uid" : product.UID, "title" : product.Title, }) # Get start page b_start = self.request.get('b_start', 0); if b_start == "None": b_start = 0 batch = Batch(result, 20, int(b_start), orphan=0) # Calculate Batch return { "batch" : batch, "next_url" : self._getNextUrl(batch), "previous_url" : self._getPreviousUrl(batch) }
def testGetProducts_3(self): """As anonymous, with product_2 published. """ wftool = getToolByName(self.shop, "portal_workflow") wftool.doActionFor(self.product_2, "publish") self.logout() pm = IProductManagement(self.shop.groups.group_1) product_ids = [p.getId() for p in pm.getProducts()] for id in ["product_1", "product_2"]: self.failUnless(id not in product_ids) pm = IProductManagement(self.shop.groups.group_2) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, [])
def testGetProducts_3(self): """As anonymous, with product_2 published. """ wftool = getToolByName(self.shop, "portal_workflow") wftool.doActionFor(self.product_2, "publish") self.logout() pm = IProductManagement(self.shop.groups.group_1) product_ids = [p.getId() for p in pm.getProducts()] for id in ["product_1", "product_2"]: self.failUnless(id not in product_ids) pm = IProductManagement(self.shop.groups.group_2) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, [])
def getAllProducts(self, sorted_on=None, sort_order=None): """ """ pm = IProductManagement(self.context) products = pm.getProducts() cm = ICategoryManagement(self.context) for category in cm.getCategories(): pm = IProductManagement(category) products.extend(pm.getProducts()) if sorted_on == "name": products = self._sortProductsByName(products, sort_order) elif sorted_on == "price": products = self._sortProductsByPrice(products, sort_order) return products
def getAllProducts(self, sorted_on=None, sort_order=None): """ """ pm = IProductManagement(self.context) products = pm.getProducts() cm = ICategoryManagement(self.context) for category in cm.getCategories(): pm = IProductManagement(category) products.extend(pm.getProducts()) if sorted_on == "name": products = self._sortProductsByName(products, sort_order) elif sorted_on == "price": products = self._sortProductsByPrice(products, sort_order) return products
def testGetProducts(self): """ """ pm = IProductManagement(self.shop) self.failIf(pm.getProducts() == 0)
def testGetProducts(self): """ """ pm = IProductManagement(self.shop) self.failIf(pm.getProducts() == 0)