def testGetPhotos(self): """ """ pm = IPhotoManagement(self.product_1) ids = [p.getId() for p in pm.getPhotos()] self.assertEqual(ids, ["photo_1", "photo_2"])
def testGetPhotos(self): """ """ pm = IPhotoManagement(self.product_1) ids = [p.getId() for p in pm.getPhotos()] self.assertEqual(ids, ["product_1"])
def testGetMainPhoto(self): """ """ pm = IPhotoManagement(self.product_1) self.assertEqual(pm.getMainPhoto().getId(), "product_1")
def testHasPhotos(self): """ """ pm = IPhotoManagement(self.product_1) self.assertEqual(pm.hasPhotos(), True)
def testGetPhotos(self): """ """ pm = IPhotoManagement(self.product_1) self.assertEqual(pm.getPhotos(), [])
def hasPhotos(self): """ """ pm = IPhotoManagement(self.context) return pm.hasPhotos()
def getPhotos(self): """ """ pm = IPhotoManagement(self.context) return pm.getPhotos()
def getMainPhoto(self): """ """ pm = IPhotoManagement(self.context) return pm.getMainPhoto()
def getInfo(self): """ """ products_per_line = self.getFormatInfo().get("products_per_line") batch = self._getBatch() # This optimized for speed, as we need _getBatch here anyway. # So there is no need of an extra method call within the page # template to get informations we have here already. Same is true # for format infos, see below batch_infos = { "previous_url": self._getPreviousUrl(batch), "previous": batch.previous, "next_url": self._getNextUrl(batch), "next": batch.next, "last_url": self._getLastUrl(batch), "navigation_list": batch.navlist, "number_of_pages": batch.numpages, "page_number": batch.pagenumber, } sorting = self.request.get("sorting", None) f = self.getFormatInfo() line = [] products = [] for index, product in enumerate(batch): cm = ICurrencyManagement(self.context) price = IPrices(product).getPriceForCustomer() price = cm.priceToString(price, symbol="symbol", position="before") # photo image = IPhotoManagement(product).getMainPhoto() if image is not None: image = "%s/image_%s" % (image.absolute_url(), f.get("image_size")) # properties view property_manager = IPropertyManagement(product) if len(property_manager.getProperties()) > 0: showSelectPropertiesView = True else: showSelectPropertiesView = False t = f.get("text") if t == "description": text = product.getDescription() elif t == "short_text": text = product.getShortText() elif t == "text": text = product.getText() else: text = "" if (index + 1) % products_per_line == 0 and products_per_line > 1: klass = "last" else: klass = "notlast" line.append({ "title": product.Title(), "short_title": product.getShortTitle() or product.Title(), "text": text, "url": "%s?sorting=%s" % (product.absolute_url(), sorting), "image": image, "price": price, "showSelectPropertiesView": showSelectPropertiesView, "class": klass, }) if (index + 1) % products_per_line == 0: products.append(line) line = [] # the rest products.append(line) # Return format infos here, because we need it anyway in this method # This is for speed reasons. See above. return { "products": products, "batch_info": batch_infos, "format_info": f, }
def getInfo(self): """ """ products_per_line = self.getFormatInfo().get("products_per_line") batch = self._getBatch() # This optimized for speed, as we need _getBatch here anyway. # So there is no need of an extra method call within the page # template to get informations we have here already. Same is true # for format infos, see below batch_infos = { "previous_url" : self._getPreviousUrl(batch), "previous" : batch.previous, "next_url" : self._getNextUrl(batch), "next" : batch.next, "last_url" : self._getLastUrl(batch), "navigation_list" : batch.navlist, "number_of_pages" : batch.numpages, "page_number" : batch.pagenumber, } sorting = self.request.get("sorting", None) f = self.getFormatInfo() line = [] products = [] for index, product in enumerate(batch): cm = ICurrencyManagement(self.context) price = IPrices(product).getPriceForCustomer() price = cm.priceToString(price, symbol="symbol", position="before") # photo image = IPhotoManagement(product).getMainPhoto() if image is not None: image = "%s/image_%s" % (image.absolute_url(), f.get("image_size")) # properties view property_manager = IPropertyManagement(product) if len(property_manager.getProperties()) > 0: showSelectPropertiesView = True else: showSelectPropertiesView = False t = f.get("text") if t == "description": text = product.getDescription() elif t == "short_text": text = product.getShortText() elif t == "text": text = product.getText() else: text = "" if (index + 1) % products_per_line == 0 and products_per_line > 1: klass = "last" else: klass = "notlast" line.append({ "title" : product.Title(), "short_title" : product.getShortTitle() or product.Title(), "text" : text, "url" : "%s?sorting=%s" % (product.absolute_url(), sorting), "image" : image, "price" : price, "showSelectPropertiesView" : showSelectPropertiesView, "class" : klass, }) if (index + 1) % products_per_line == 0: products.append(line) line = [] # the rest products.append(line) # Return format infos here, because we need it anyway in this method # This is for speed reasons. See above. return { "products" : products, "batch_info" : batch_infos, "format_info" : f, }