def tiles(self): tile_items = [] self.query_tile_items(self.context, tile_items) sm = getSecurityManager() for tile_item in tile_items: item_context = self.tile_item_context(tile_item) if IBuyable.providedBy(item_context) and sm.checkPermission( permissions.ViewBuyableInfo, item_context): buyable_url = item_context.absolute_url() else: buyable_url = None item_scale = img_scale(tile_item, self.tile_item_image_scale) if item_scale is not None: item_preview = item_scale.url else: item_preview = "++resource++dummy_product.jpg" item_style = """ background-image:url('{image}'); background-size:cover; background-position:center; background-repeat:no-repeat; """.format(image=item_preview) item_description = item_context.Description() item_description = (item_description and item_description[:60] + "..." or None) yield { "display": True, "title": item_context.Title(), "description": item_description, "url": item_context.absolute_url(), "style": item_style, "buyable_url": buyable_url, }
def __init__(self, context): permissions = [VIEW_ORDERS_PERMISSION] super(ShopPortletBookingsInContextLink, self).__init__( context, view_permissions=permissions) # check if authenticated user is vendor if self.display and not get_vendors_for(): self.display = False # Go to appropriate context if not IBuyable.providedBy(context) \ and not IFolder.providedBy(context) \ and not IPloneSiteRoot.providedBy(context): context = context.aq_inner.aq_parent self.url = '%s/@@bookings' % context.absolute_url() self.title = _('bookings_in_context', default=u'Bookings in Context') self.order = 22 self.cssclass = 'bookings'
def __init__(self, context): permissions = [VIEW_ORDERS_PERMISSION] super(ShopPortletOrdersInContextLink, self).__init__(context, view_permissions=permissions) # check if authenticated user is vendor if self.display and not get_vendors_for(): self.display = False # Go to appropriate context if ( not IBuyable.providedBy(context) and not IFolder.providedBy(context) and not IPloneSiteRoot.providedBy(context) ): context = context.aq_inner.aq_parent self.url = "%s/@@orders" % context.absolute_url() self.title = _("orders_in_context", default=u"Orders in Context") self.order = 11 self.cssclass = "orders"
def __init__(self, context): assert IBuyable.providedBy(context) self.context = context