Exemplo n.º 1
0
 def currency(self):
     settings = get_shop_settings()
     currency = settings.currency
     show_currency = settings.show_currency
     if show_currency == 'symbol':
         currency = CURRENCY_LITERALS[currency]
     return currency
Exemplo n.º 2
0
 def currency(self):
     settings = get_shop_settings()
     currency = settings.currency
     show_currency = settings.show_currency
     if show_currency == 'symbol':
         currency = CURRENCY_LITERALS[currency]
     return currency
Exemplo n.º 3
0
 def test_is_customer(self):
     """Test if a newly created user is granted the "Customer" role.
     """
     self.assertTrue(get_shop_settings().add_customer_role_to_new_users)
     plone.api.user.create(
         email="*****@*****.**", username="******", password="******"
     )
     self.assertTrue("Customer" in plone.api.user.get_roles(username="******"))
Exemplo n.º 4
0
def add_customer_role(event):
    try:
        if not get_shop_settings().add_customer_role_to_new_users:
            return
    except KeyError:
        return
    username = event.principal.getUserName()
    apiuser.grant_roles(username=username, roles=['Customer'])
Exemplo n.º 5
0
def add_customer_role(event):
    try:
        if not get_shop_settings().add_customer_role_to_new_users:
            return
        username = event.principal.getUserName()
        apiuser.grant_roles(username=username, roles=["Customer"])
    except ComponentLookupError:
        # failing on ``bin/instance adduser`` due to uninitialized registry
        # on startup.
        return
Exemplo n.º 6
0
def add_customer_role(event):
    try:
        if not get_shop_settings().add_customer_role_to_new_users:
            return
        username = event.principal.getUserName()
        apiuser.grant_roles(username=username, roles=['Customer'])
    except ComponentLookupError:
        # failing on ``bin/instance adduser`` due to uninitialized registry
        # on startup.
        return
Exemplo n.º 7
0
 def test_is_customer(self):
     """Test if a newly created user is granted the "Customer" role.
     """
     self.assertTrue(get_shop_settings().add_customer_role_to_new_users)
     plone.api.user.create(
         email="*****@*****.**",
         username="******",
         password="******"
     )
     self.assertTrue(
         'Customer' in plone.api.user.get_roles(username="******")
     )
Exemplo n.º 8
0
    def description(self):
        settings = get_shop_shipping_settings()
        currency = get_shop_settings().currency
        show_currency = get_shop_settings().show_currency
        if show_currency == 'symbol':
            currency = CURRENCY_LITERALS[currency]
        shipping_limit_from_gross = settings.shipping_limit_from_gross
        free_shipping_limit = Decimal(str(settings.free_shipping_limit))
        flat_shipping_cost = Decimal(str(settings.flat_shipping_cost))
        item_shipping_cost = Decimal(str(settings.item_shipping_cost))
        shipping_vat = Decimal(str(settings.shipping_vat))

        def gross(val):
            return format_amount(val + (val / Decimal(100) * shipping_vat))

        # no shipping costs
        if not flat_shipping_cost and not item_shipping_cost:
            return _(u"free_shipping", default=u"Free Shipping")
        # no free shipping limit
        if not free_shipping_limit:
            # flat and item costs defined
            if flat_shipping_cost and item_shipping_cost:
                msg = _(u"no_free_shipping_flat_and_item",
                        default=u"Minimum ${flat} ${currency} or ${item} "
                                u"${currency} per item in cart")
                return Message(msg, mapping={
                    'flat': gross(flat_shipping_cost),
                    'item': gross(item_shipping_cost),
                    'currency': currency,
                })
            # flat costs only
            if flat_shipping_cost and not item_shipping_cost:
                msg = _(u"no_free_shipping_flat_only",
                        default=u"Flat ${flat} ${currency}")
                return Message(msg, mapping={
                    'flat': gross(flat_shipping_cost),
                    'currency': currency,
                })
            # item costs only
            if not flat_shipping_cost and item_shipping_cost:
                msg = _(u"no_free_shipping_item_only",
                        default=u"${item} ${currency} per item in cart")
                return Message(msg, mapping={
                    'item': gross(item_shipping_cost),
                    'currency': currency,
                })
        # free shipping above limit
        # flat and item costs defined
        if flat_shipping_cost and item_shipping_cost:
            # from gross
            if shipping_limit_from_gross:
                msg = _(u"free_shipping_limit_flat_and_item_gross",
                        default=u"Minimum ${flat} ${currency} or "
                                u"${item} ${currency} per item in cart. Free "
                                u"shipping if gross purchase price above "
                                u"${limit} ${currency}")
            # from net
            else:
                msg = _(u"free_shipping_limit_flat_and_item_net",
                        default=u"Minimum ${flat} ${currency} or "
                                u"${item} ${currency} per item in cart. Free "
                                u"shipping if net purchase price above "
                                u"${limit} ${currency}")
            return Message(msg, mapping={
                'flat': gross(flat_shipping_cost),
                'item': gross(item_shipping_cost),
                'limit': format_amount(free_shipping_limit),
                'currency': currency,
            })
        # flat costs only
        if flat_shipping_cost and not item_shipping_cost:
            # from gross
            if shipping_limit_from_gross:
                msg = _(u"free_shipping_limit_flat_only_gross",
                        default=u"Flat ${flat} ${currency}. Free "
                                u"shipping if gross purchase price above "
                                u"${limit} ${currency}")
            # from net
            else:
                msg = _(u"free_shipping_limit_flat_only_net",
                        default=u"Flat ${flat} ${currency}. Free "
                                u"shipping if net purchase price above "
                                u"${limit} ${currency}")
            return Message(msg, mapping={
                'flat': gross(flat_shipping_cost),
                'limit': format_amount(free_shipping_limit),
                'currency': currency,
            })
        # item costs only
        if not flat_shipping_cost and item_shipping_cost:
            # from gross
            if shipping_limit_from_gross:
                msg = _(u"free_shipping_limit_item_only_gross",
                        default=u"${item} ${currency} per item in "
                                u"cart. Free shipping if gross purchase "
                                u"price above ${limit} ${currency}")
            # from net
            else:
                msg = _(u"free_shipping_limit_item_only_net",
                        default=u"${item} ${currency} per item in "
                                u"cart. Free shipping if net purchase "
                                u"price above ${limit} ${currency}")
            return Message(msg, mapping={
                'item': gross(item_shipping_cost),
                'limit': format_amount(free_shipping_limit),
                'currency': currency,
            })
Exemplo n.º 9
0
 def show_currency(self):
     return get_shop_settings().show_currency
Exemplo n.º 10
0
 def currency(self):
     return get_shop_settings().currency
Exemplo n.º 11
0
 def show_currency(self):
     return get_shop_settings().show_currency
Exemplo n.º 12
0
 def shopmaster_mail(self):
     return get_shop_settings().admin_email
Exemplo n.º 13
0
    def description(self):
        settings = get_shop_shipping_settings()
        currency = get_shop_settings().currency
        show_currency = get_shop_settings().show_currency
        if show_currency == 'symbol':
            currency = CURRENCY_LITERALS[currency]
        shipping_limit_from_gross = settings.shipping_limit_from_gross
        free_shipping_limit = Decimal(str(settings.free_shipping_limit))
        flat_shipping_cost = Decimal(str(settings.flat_shipping_cost))
        item_shipping_cost = Decimal(str(settings.item_shipping_cost))
        shipping_vat = Decimal(str(settings.shipping_vat))

        def gross(val):
            return format_amount(val + (val / Decimal(100) * shipping_vat))

        # no shipping costs
        if not flat_shipping_cost and not item_shipping_cost:
            return _(u"free_shipping", default=u"Free Shipping")
        # no free shipping limit
        if not free_shipping_limit:
            # flat and item costs defined
            if flat_shipping_cost and item_shipping_cost:
                msg = _(u"no_free_shipping_flat_and_item",
                        default=u"Minimum ${flat} ${currency} or ${item} "
                        u"${currency} per item in cart")
                return Message(msg,
                               mapping={
                                   'flat': gross(flat_shipping_cost),
                                   'item': gross(item_shipping_cost),
                                   'currency': currency,
                               })
            # flat costs only
            if flat_shipping_cost and not item_shipping_cost:
                msg = _(u"no_free_shipping_flat_only",
                        default=u"Flat ${flat} ${currency}")
                return Message(msg,
                               mapping={
                                   'flat': gross(flat_shipping_cost),
                                   'currency': currency,
                               })
            # item costs only
            if not flat_shipping_cost and item_shipping_cost:
                msg = _(u"no_free_shipping_item_only",
                        default=u"${item} ${currency} per item in cart")
                return Message(msg,
                               mapping={
                                   'item': gross(item_shipping_cost),
                                   'currency': currency,
                               })
        # free shipping above limit
        # flat and item costs defined
        if flat_shipping_cost and item_shipping_cost:
            # from gross
            if shipping_limit_from_gross:
                msg = _(u"free_shipping_limit_flat_and_item_gross",
                        default=u"Minimum ${flat} ${currency} or "
                        u"${item} ${currency} per item in cart. Free "
                        u"shipping if gross purchase price above "
                        u"${limit} ${currency}")
            # from net
            else:
                msg = _(u"free_shipping_limit_flat_and_item_net",
                        default=u"Minimum ${flat} ${currency} or "
                        u"${item} ${currency} per item in cart. Free "
                        u"shipping if net purchase price above "
                        u"${limit} ${currency}")
            return Message(msg,
                           mapping={
                               'flat': gross(flat_shipping_cost),
                               'item': gross(item_shipping_cost),
                               'limit': format_amount(free_shipping_limit),
                               'currency': currency,
                           })
        # flat costs only
        if flat_shipping_cost and not item_shipping_cost:
            # from gross
            if shipping_limit_from_gross:
                msg = _(u"free_shipping_limit_flat_only_gross",
                        default=u"Flat ${flat} ${currency}. Free "
                        u"shipping if gross purchase price above "
                        u"${limit} ${currency}")
            # from net
            else:
                msg = _(u"free_shipping_limit_flat_only_net",
                        default=u"Flat ${flat} ${currency}. Free "
                        u"shipping if net purchase price above "
                        u"${limit} ${currency}")
            return Message(msg,
                           mapping={
                               'flat': gross(flat_shipping_cost),
                               'limit': format_amount(free_shipping_limit),
                               'currency': currency,
                           })
        # item costs only
        if not flat_shipping_cost and item_shipping_cost:
            # from gross
            if shipping_limit_from_gross:
                msg = _(u"free_shipping_limit_item_only_gross",
                        default=u"${item} ${currency} per item in "
                        u"cart. Free shipping if gross purchase "
                        u"price above ${limit} ${currency}")
            # from net
            else:
                msg = _(u"free_shipping_limit_item_only_net",
                        default=u"${item} ${currency} per item in "
                        u"cart. Free shipping if net purchase "
                        u"price above ${limit} ${currency}")
            return Message(msg,
                           mapping={
                               'item': gross(item_shipping_cost),
                               'limit': format_amount(free_shipping_limit),
                               'currency': currency,
                           })
Exemplo n.º 14
0
def add_customer_role(event):
    if not get_shop_settings().add_customer_role_to_new_users:
        return
    username = event.principal.getUserName()
    apiuser.grant_roles(username=username, roles=['Customer'])
Exemplo n.º 15
0
 def admin_name(self):
     props = getToolByName(self.context, 'portal_properties')
     return get_shop_settings().admin_name or \
         props.site_properties.email_from_name
Exemplo n.º 16
0
 def admin_name(self):
     props = api.portal.get_tool("portal_properties")
     return get_shop_settings().admin_name or getattr(
         props.site_properties, "email_from_name", "")
Exemplo n.º 17
0
def default_item_display_gross(context):
    return get_shop_settings().default_item_display_gross
Exemplo n.º 18
0
 def admin_name(self):
     props = api.portal.get_tool('portal_properties')
     return (get_shop_settings().admin_name
             or getattr(props.site_properties, 'email_from_name', ''))
Exemplo n.º 19
0
 def currency(self):
     return get_shop_settings().currency
Exemplo n.º 20
0
def default_item_display_gross(context):
    return lambda: get_shop_settings().default_item_display_gross
Exemplo n.º 21
0
def shopmaster_mail(context):
    return get_shop_settings().admin_email
Exemplo n.º 22
0
 def admin_name(self):
     props = api.portal.get_tool('portal_properties')
     return (
         get_shop_settings().admin_name or
         getattr(props.site_properties, 'email_from_name', '')
     )