Example #1
0
    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'
Example #2
0
    def __init__(self, context):
        permissions = [MANAGE_TEAMPLETS_PERMISSION]
        super(ShopPortletMailTemplatesLink, self).__init__(
            context, view_permissions=permissions)

        # 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 = _(
                'mailtemplates_global',
                default=u'Notification Templates (global)'
            )
        elif ISite.providedBy(context):
            self.title = _(
                'mailtemplates_site',
                default=u'Notification Templates (site-wide)'
            )
        elif IVendor.providedBy(context):
            self.title = _(
                'mailtemplates_vendor',
                default=u'Notification Templates (vendor specific)'
            )

        self.url = '%s/@@mailtemplates' % context.absolute_url()
        self.order = 50
        self.cssclass = 'mailtemplates'
Example #3
0
def acquire_vendor_or_shop_root(context):
    """Returns the acquired vendor or the main shop by traversing up the
    content tree, starting from a context.

    :param context: The context to start searching for the nearest vendor.
    :type context: Content object
    :returns: The vendor, a shop item is belonging to.
    :rtype: Content object
    """
    while not IVendor.providedBy(context) and not ISite.providedBy(context):
        context = aq_parent(aq_inner(context))
    return context
Example #4
0
 def __init__(self, context):
     permissions = [
         MANAGE_PORTAL, MODIFY_CONTENT_PERMISSION,
     ]
     super(ShopAdminMailTemplatesLink, self).__init__(
         context, view_permissions=permissions)
     if self.display:
         self.display = IPloneSiteRoot.providedBy(context) \
             or IVendor.providedBy(context)
     self.url = '%s/@@mailtemplates' % context.absolute_url()
     self.title = _('mailtemplates', default=u'Notification Templates')
     self.order = 40
Example #5
0
def acquire_vendor_or_shop_root(context):
    """Returns the acquired vendor or the main shop by traversing up the
    content tree, starting from a context.

    :param context: The context to start searching for the nearest vendor.
    :type context: Content object
    :returns: The vendor, a shop item is belonging to.
    :rtype: Content object
    """
    if not context:
        message = u"No context given to acquire vendor or shop root from"
        raise ValueError(message)
    while not IVendor.providedBy(context) \
            and not IPloneSiteRoot.providedBy(context):
        context = aq_parent(aq_inner(context))
    return context
Example #6
0
def acquire_vendor_or_shop_root(context):
    """Returns the acquired vendor or the main shop by traversing up the
    content tree, starting from a context.

    :param context: The context to start searching for the nearest vendor.
    :type context: Content object
    :returns: The vendor, a shop item is belonging to.
    :rtype: Content object
    """
    if not context:
        message = u"No context given to acquire vendor or shop root from"
        raise ValueError(message)
    while not IVendor.providedBy(context) \
            and not IPloneSiteRoot.providedBy(context):
        context = aq_parent(aq_inner(context))
    return context
Example #7
0
 def __init__(self, context, request):
     # acquire desired context
     context = self.acquire_context(context, interfaces=[IVendor, ISite])
     # call super class constructor
     super(MailTemplatesLink, self).__init__(context, request)
     # set title by context interface
     if IPloneSiteRoot.providedBy(context):
         self.title = _('mailtemplates_global',
                        default=u'Notification Templates (global)')
     elif ISite.providedBy(context):
         self.title = _('mailtemplates_site',
                        default=u'Notification Templates (site-wide)')
     elif IVendor.providedBy(context):
         self.title = _('mailtemplates_vendor',
                        default=u'Notification Templates (vendor specific)')
     # set target URL
     self.url = '{}/@@mailtemplates'.format(context.absolute_url())
Example #8
0
 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
     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())
Example #10
0
 def __init__(self, context, request):
     # acquire desired context
     context = self.acquire_context(context, interfaces=[IVendor, ISite])
     # call super class constructor
     super(MailTemplatesLink, self).__init__(context, request)
     # set title by context interface
     if IPloneSiteRoot.providedBy(context):
         self.title = _(
             'mailtemplates_global',
             default=u'Notification Templates (global)'
         )
     elif ISite.providedBy(context):
         self.title = _(
             'mailtemplates_site',
             default=u'Notification Templates (site-wide)'
         )
     elif IVendor.providedBy(context):
         self.title = _(
             'mailtemplates_vendor',
             default=u'Notification Templates (vendor specific)'
         )
     # set target URL
     self.url = '{}/@@mailtemplates'.format(context.absolute_url())
Example #11
0
 def _find_context(ctx):
     return ctx if ISite.providedBy(ctx) or IVendor.providedBy(ctx) else _find_context(aq_parent(ctx))