コード例 #1
0
ファイル: category.py プロジェクト: mistub70/ftw.shop
 def getItems(self):
     """Returns a list of ShopItems directly contained in this category
     """
     return [
         item for item in self.category_contents
         if IShopItem.providedBy(item)
     ]
コード例 #2
0
ファイル: cart.py プロジェクト: mistub70/ftw.shop
 def context_has_shopitems(self):
     shopitem_ifaces = ['ftw.shop.interfaces.IShopItem',
                         'ftwshop.simplelayout.interfaces.IShopItemBlock']
     shop_contents = self.context.getFolderContents(
                         contentFilter={'object_provides': shopitem_ifaces})
     if shop_contents or IShopItem.providedBy(self.context):
         return True
     return False
コード例 #3
0
ファイル: category.py プロジェクト: kattaprasanth/ftw.shop
    def getItemDatas(self):
        """Returns a dictionary of an item's properties to be used in
        templates. If the item has variations, the variation config is
        also included.
        """
        results = []
        for item in self.getItems():
            assert(IShopItem.providedBy(item))
            varConf = IVariationConfig(item)

            has_variations = varConf.hasVariations()

            image = item.getField('image')
            if image and image.get_size(item):
                hasImage = True
                tag = image.tag(item, scale='mini')
            else:
                hasImage = False
                tag = None
            if has_variations:
                skuCode = None
                price = None
            else:
                varConf = None
                skuCode = item.Schema().getField('skuCode').get(item)
                price = item.Schema().getField('price').get(item)

            results.append(
                dict(
                    item = item,
                    title = item.Title(),
                    description = item.Description(),
                    url = item.absolute_url(),
                    hasImage = hasImage,
                    imageTag = tag,
                    variants = None,
                    skuCode = skuCode,
                    price = price,
                    showPrice = item.getField('showPrice').get(item),
                    unit=item.getField('unit').get(item),
                    uid = item.UID(),
                    varConf = varConf,
                    hasVariations = has_variations,
                    selectable_dimensions = item.getSelectableDimensions()))
        return results
コード例 #4
0
ファイル: category.py プロジェクト: jianaijun/ftw.shop
 def getItems(self):
     """Returns a list of ShopItems directly contained in this category
     """
     return [item for item in self.category_contents
             if IShopItem.providedBy(item)]