def __init__(self, context): permissions = [VIEW_ORDERS_PERMISSION] super(ShopPortletOrdersLink, self).__init__( context, view_permissions=permissions) # check if authenticated user is vendor if self.display and not get_vendors_for(): self.display = False # Find the nearest context, where this functionality can be bound to. def _find_context(ctx): return ctx\ if ISite.providedBy(ctx) or IVendor.providedBy(ctx)\ else _find_context(aq_parent(ctx)) context = _find_context(context) if IPloneSiteRoot.providedBy(context): self.title = _( 'orders_global', default=u'Orders (global)' ) elif ISite.providedBy(context): self.title = _( 'orders_site', default=u'Orders (site-wide)' ) elif IVendor.providedBy(context): self.title = _( 'orders_vendor', default=u'Orders (vendor specific)' ) self.url = '%s/@@orders' % context.absolute_url() self.order = 10 self.cssclass = 'orders'
def vendors_vocab_for(user=None): """Vendors vocabulary for given or currently authenticated user. """ vendors = get_vendors_for(user=user) vocab = [(IUUID(vendor), u'{0} ({1})'.format(vendor.Title(), vendor.absolute_url_path())) for vendor in vendors] return vocab
def vendors_vocab_for(user=None): """Vendors vocabulary for given or currently authenticated user. """ vendors = get_vendors_for(user=user) vocab = [(IUUID(vendor), '{0} ({1})'.format(vendor.Title(), vendor.absolute_url_path())) for vendor in vendors] return vocab
def __call__(self): # check if authenticated user is vendor if not get_vendors_for(): raise Unauthorized # disable diazo theming if ajax call if '_' in self.request.form: self.request.response.setHeader('X-Theme-Disabled', 'True') return super(RedeemTable, self).__call__()
def __call__(self): # check if authenticated user is vendor if not get_vendors_for(): raise Unauthorized # disable diazo theming if ajax call if '_' in self.request.form: self.request.response.setHeader('X-Theme-Disabled', 'True') return super(OrdersTable, self).__call__()
def __call__(self): # check if authenticated user is vendor if not get_vendors_for(): raise Unauthorized self.prepare() controller = Controller(self.form, self.request) if not controller.next: self.rendered_form = controller.rendered return self.browser_template(self) return controller.next
def __init__(self, context, request): # acquire desired context context = self.acquire_context(context, interfaces=[ISite]) # call super class constructor super(ContactsLink, self).__init__(context, request) # check if authenticated user is vendor if self.display and not get_vendors_for(): self.display = False return # set target URL self.url = '{}/@@contacts'.format(context.absolute_url())
def __init__(self, context, request): # acquire desired context context = self.acquire_context(context, interfaces=[ISite]) # call super class constructor super(ContactsLink, self).__init__(context, request) # check if authenticated user is vendor if self.display and not get_vendors_for(): self.display = False return # set target URL self.url = "{}/@@contacts".format(context.absolute_url())
def __init__(self, context): permissions = [VIEW_ORDERS_PERMISSION] super(ShopPortletContactsLink, self).__init__(context, view_permissions=permissions) # check if authenticated user is vendor if self.display and not get_vendors_for(): self.display = False site = plone.api.portal.get() self.url = "%s/@@contacts" % site.absolute_url() self.title = _("contacts", default=u"Contacts") self.order = 23 self.cssclass = "bookings"
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, request): # acquire desired context context = self.acquire_context(context, interfaces=[IVendor, ISite]) # call super class constructor super(BookingsLink, self).__init__(context, request) # check if authenticated user is vendor if self.display and not get_vendors_for(): self.display = False return # set title by context interface if IPloneSiteRoot.providedBy(context): self.title = _("bookings_global", default=u"Bookings (global)") elif ISite.providedBy(context): self.title = _("bookings_site", default=u"Bookings (site-wide)") elif IVendor.providedBy(context): self.title = _("bookings_vendor", default=u"Bookings (vendor specific)") # set target URL self.url = "{}/@@bookings".format(context.absolute_url())
def __init__(self, context, request): # acquire desired context interfaces = [IBuyable, IFolder, ISite] context = self.acquire_context(context, interfaces=interfaces) # skip link if context is vendor or site if self.context_provides(context, interfaces=[IVendor, ISite]): self.display = False return # call super class constructor super(BookingsInContextLink, self).__init__(context, request) # check if authenticated user is vendor if self.display and not get_vendors_for(): self.display = False return # check if buyables in context if self.display and not self.buyables_in_context(context): self.display = False return # set target URL self.url = '{}/@@bookings'.format(context.absolute_url())
def __init__(self, context, request): # acquire desired context interfaces = [IBuyable, IFolder, ISite] context = self.acquire_context(context, interfaces=interfaces) # skip link if context is vendor or site if self.context_provides(context, interfaces=[IVendor, ISite]): self.display = False return # call super class constructor super(BookingsInContextLink, self).__init__(context, request) # check if authenticated user is vendor if self.display and not get_vendors_for(): self.display = False return # check if buyables in context if self.display and not self.buyables_in_context(context): self.display = False return # set target URL self.url = "{}/@@bookings".format(context.absolute_url())
def __init__(self, context, request): # acquire desired context context = self.acquire_context(context, interfaces=[IVendor, ISite]) # call super class constructor super(BookingsLink, self).__init__(context, request) # check if authenticated user is vendor if self.display and not get_vendors_for(): self.display = False return # set title by context interface if IPloneSiteRoot.providedBy(context): self.title = _('bookings_global', default=u'Bookings (global)') elif ISite.providedBy(context): self.title = _('bookings_site', default=u'Bookings (site-wide)') elif IVendor.providedBy(context): self.title = _( 'bookings_vendor', default=u'Bookings (vendor specific)' ) # set target URL self.url = '{}/@@bookings'.format(context.absolute_url())
def __call__(self): # check if authenticated user is vendor if not get_vendors_for(): raise Unauthorized return super(OrdersTable, self).__call__()
def __call__(self): # check if authenticated user is vendor if not get_vendors_for(): raise Unauthorized return super(RedeemView, self).__call__()
def __call__(self): # check if authenticated user is vendor if not get_vendors_for(): raise Unauthorized return super(OrdersView, self).__call__()