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
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="******"))
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'])
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
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
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="******") )
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, })
def show_currency(self): return get_shop_settings().show_currency
def currency(self): return get_shop_settings().currency
def shopmaster_mail(self): return get_shop_settings().admin_email
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'])
def admin_name(self): props = getToolByName(self.context, 'portal_properties') return get_shop_settings().admin_name or \ props.site_properties.email_from_name
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", "")
def default_item_display_gross(context): return get_shop_settings().default_item_display_gross
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', ''))
def default_item_display_gross(context): return lambda: get_shop_settings().default_item_display_gross
def shopmaster_mail(context): return get_shop_settings().admin_email
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', '') )