Пример #1
0
    def testGetImages(self):
        """
        """
        pm = IImageManagement(self.product_1)
        ids = [p.getId() for p in pm.getImages()]

        self.assertEqual(ids, ["image_1", "image_2"])
Пример #2
0
    def testGetImages(self):
        """
        """
        pm = IImageManagement(self.product_1)
        ids = [p.getId() for p in pm.getImages()]

        self.assertEqual(ids, ["image_1", "image_2"])
Пример #3
0
    def getImageUrls(self):
        """
        """
        pm = IImageManagement(self.context)

        result = []
        for image in pm.getImages():
            result.append(
                "%s/image_tile"  % image.absolute_url(),
            )

        return result
Пример #4
0
    def getImageUrls(self):
        """
        """
        pm = IImageManagement(self.context)

        result = []
        for image in pm.getImages():
            result.append({
                "small" : "%s/image_thumb"  % image.absolute_url(),
                "large" : "%s/image_large" % image.absolute_url(),
            })
                        
        return result
Пример #5
0
    def getImageUrls(self):
        """
        """
        pm = IImageManagement(self.context)

        result = []
        for image in pm.getImages():
            result.append({
                "small": "%s/image_thumb" % image.absolute_url(),
                "large": "%s/image_large" % image.absolute_url(),
            })

        return result
Пример #6
0
 def testGetImages(self):
     """
     """
     pm = IImageManagement(self.product_1)
     self.assertEqual(pm.getImages(), [])
Пример #7
0
 def testGetImages(self):
     """
     """
     pm = IImageManagement(self.product_1)
     self.assertEqual(pm.getImages(), [])
Пример #8
0
    def getProducts(self):
        """
        """
        catalog = getToolByName(self.context, "portal_catalog")
        brains = catalog.searchResults(portal_type="Product")

        result = []

        line = [
            "Title",
            "Url",
            "Price",
            "Short Title",
            "Article ID",
            "Description",
            "Weight",
            "Text",
            "Short Text",
            "Image",
        ]

        line = ['"%s"' % field for field in line]
        line = "\t".join(line)

        result.append(line)

        for brain in brains:
            product = brain.getObject()

            # Price
            price = IPrices(product).getPriceGross()

            # This is crap and has to be optimized.
            text = product.getText()
            text = text.replace("\n", "")
            text = text.replace("\r", "")
            text = text.replace("\t", "")

            short_text = product.getShortText()
            short_text = short_text.replace("\n", "")
            short_text = short_text.replace("\r", "")
            short_text = short_text.replace("\t", "")

            description = product.Description()
            description = description.replace("\n", "")
            description = description.replace("\r", "")
            description = description.replace("\t", "")

            line = [
                product.Title(),
                product.absolute_url(),
                price,
                product.getShortTitle(),
                product.getArticleId(),
                description,
                product.getWeight(),
                text,
                short_text,
            ]

            # Images
            im = IImageManagement(product)
            for image in im.getImages():
                if image.absolute_url() == product.absolute_url():
                    url = image.absolute_url() + "/image"
                else:
                    url = image.absolute_url()
                line.append(url)

            line = ['"%s"' % field for field in line]
            line = "\t".join(line)

            result.append(line)

        self.request.response.setHeader('Content-type', 'text/plain')
        self.request.response.setHeader(
            'Content-disposition', 'attachment; filename=%s' % "products.txt")

        return "\r\n".join(result)
Пример #9
0
    def getProducts(self):
        """
        """
        catalog = getToolByName(self.context, "portal_catalog")
        brains = catalog.searchResults(
            portal_type = "Product"
        )

        result = []

        line = [
            "Title",
            "Url",  
            "Price",          
            "Short Title",
            "Article ID",
            "Description",
            "Weight",
            "Text",
            "Short Text",
            "Image",]

        line = ['"%s"' % field for field in line]
        line = "\t".join(line)
        
        result.append(line)
            
        for brain in brains:
            product = brain.getObject()
            
            # Price 
            price = IPrices(product).getPriceGross()
            
            # This is crap and has to be optimized.
            text = product.getText()
            text = text.replace("\n", "")
            text = text.replace("\r", "")
            text = text.replace("\t", "")

            short_text = product.getShortText()
            short_text = short_text.replace("\n", "")
            short_text = short_text.replace("\r", "")
            short_text = short_text.replace("\t", "")

            description = product.Description()
            description = description.replace("\n", "")
            description = description.replace("\r", "")
            description = description.replace("\t", "")
            
            line = [
                product.Title(),
                product.absolute_url(),
                price,
                product.getShortTitle(),
                product.getArticleId(),
                description,
                product.getWeight(),
                text,
                short_text,
            ]
                        
            # Images 
            im = IImageManagement(product)
            for image in im.getImages():
                if image.absolute_url() == product.absolute_url():
                    url = image.absolute_url() + "/image"
                else:
                    url = image.absolute_url()
                line.append(url)
                
            line = ['"%s"' % field for field in line]
            line = "\t".join(line)
            
            result.append(line)
            
        self.request.response.setHeader('Content-type', 'text/plain')
        self.request.response.setHeader(
            'Content-disposition',
            'attachment; filename=%s' % "products.txt"
        )

        return "\r\n".join(result)