コード例 #1
0
    def getProducts(self):
        """
        """
        selector = getattr(self.context, "thank-you", None)
        if selector is None: return []

        mtool = getToolByName(self.context, "portal_membership")

        result = []
        for product in selector.getRefs():

            if mtool.checkPermission("View", product) is None:
                continue

            # image
            pm = IImageManagement(product)
            image = pm.getMainImage()
            if image is None:
                image = None
            else:
                image = "%s/image_shop_small" % image.absolute_url()

            cm = ICurrencyManagement(self.context)
            price = IPrices(product).getPriceForCustomer()
            price = cm.priceToString(price)

            result.append({
                "title":
                product.Title(),
                "short_title":
                product.getShortTitle() or product.Title(),
                "url":
                product.absolute_url(),
                "price":
                price,
                "image":
                image,
            })

        return result
コード例 #2
0
ファイル: thank_you.py プロジェクト: ned14/Easyshop
    def getProducts(self):
        """
        """
        selector = getattr(self.context, "thank-you", None)
        if selector is None:
            return []

        mtool = getToolByName(self.context, "portal_membership")

        result = []
        for product in selector.getRefs():

            if mtool.checkPermission("View", product) is None:
                continue

            # image
            pm = IImageManagement(product)
            image = pm.getMainImage()
            if image is None:
                image = None
            else:
                image = "%s/image_shop_small" % image.absolute_url()

            cm = ICurrencyManagement(self.context)
            price = IPrices(product).getPriceForCustomer()
            price = cm.priceToString(price)

            result.append(
                {
                    "title": product.Title(),
                    "short_title": product.getShortTitle() or product.Title(),
                    "url": product.absolute_url(),
                    "price": price,
                    "image": image,
                }
            )

        return result
コード例 #3
0
 def testGetMainImage(self):
     """
     """
     pm = IImageManagement(self.product_1)
     self.assertEqual(pm.getMainImage().getId(), "product_1")
コード例 #4
0
 def testGetMainImage(self):
     """
     """
     pm = IImageManagement(self.product_1)
     self.assertEqual(pm.getMainImage().getId(), "product_1")