本文整理汇总了Python中satchmo_utils.templatetags.get_filter_args函数的典型用法代码示例。如果您正苦于以下问题:Python get_filter_args函数的具体用法?Python get_filter_args怎么用?Python get_filter_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_filter_args函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_stripquotes_get_args
def test_stripquotes_get_args(self):
args, kwargs = get_filter_args('"test",one="test",two=2', stripquotes=True)
self.assertEqual(args[0], "test")
self.assertEqual(kwargs["one"], "test")
self.assertEqual(kwargs["two"], "2")
args, kwargs = get_filter_args('"test",one="test",two=2', stripquotes=False)
self.assertEqual(args[0], '"test"')
self.assertEqual(kwargs["one"], '"test"')
开发者ID:hnejadi,项目名称:xerobis,代码行数:12,代码来源:tests.py
示例2: test_numerical_get_args
def test_numerical_get_args(self):
args, kwargs = get_filter_args("test,one=1,two=2", (), ("one", "two"))
self.assertEqual(args[0], "test")
self.assertEqual(kwargs["one"], 1)
self.assertEqual(kwargs["two"], 2)
开发者ID:hnejadi,项目名称:xerobis,代码行数:7,代码来源:tests.py
示例3: test_extended_get_args
def test_extended_get_args(self):
args, kwargs = get_filter_args("test,one=1,two=2")
self.assertEqual(args[0], "test")
self.assertEqual(kwargs["one"], "1")
self.assertEqual(kwargs["two"], "2")
开发者ID:hnejadi,项目名称:xerobis,代码行数:7,代码来源:tests.py
示例4: test_simple_get_args
def test_simple_get_args(self):
args, kwargs = get_filter_args("one=1,two=2")
self.assertEqual(len(args), 0)
self.assertEqual(kwargs["one"], "1")
self.assertEqual(kwargs["two"], "2")
开发者ID:hnejadi,项目名称:xerobis,代码行数:7,代码来源:tests.py
示例5: random_testimonials
def random_testimonials(tg, args):
args, kwargs = get_filter_args(args, intargs=('length',))
ct = kwargs.get('length', 4)
if tg:
return tg.random_testimonies(ct)
else:
return []
开发者ID:typerlc,项目名称:artlab_satchmo,代码行数:7,代码来源:testimonial_tags.py
示例6: test_keystrip_get_args
def test_keystrip_get_args(self):
args, kwargs = get_filter_args("test,one=1,two=2", ("one"), ("one"))
self.assertEqual(args[0], "test")
self.assertEqual(kwargs["one"], 1)
self.assertFalse("two" in kwargs)
开发者ID:hnejadi,项目名称:xerobis,代码行数:7,代码来源:tests.py
示例7: currency
def currency(value, args=""):
"""Convert a value to a money formatted string.
places: required number of places after the decimal point
curr: optional currency symbol before the sign (may be blank)
wrapcents:tag to wrap the part after the decimal point
Usage:
val|currency
val|currency:'places=2'
val|currency:'places=2:wrapcents=sup'
"""
if value == '' or value is None:
return value
args, kwargs = get_filter_args(args,
keywords=('places','curr', 'wrapcents'),
intargs=('places',), stripquotes=True)
try:
value = Decimal(str(value))
except InvalidOperation:
log.error("Could not convert value '%s' to decimal", value)
raise
if not 'places' in kwargs:
kwargs['places'] = 2
return mark_safe(moneyfmt(value, **kwargs))
开发者ID:hnejadi,项目名称:xerobis,代码行数:30,代码来源:satchmo_currency.py
示例8: test_numerical_get_args
def test_numerical_get_args(self):
args, kwargs = get_filter_args('test,one=1,two=2', (), ('one','two'))
self.assertEqual(args[0], 'test')
self.assertEqual(kwargs['one'], 1)
self.assertEqual(kwargs['two'], 2)
开发者ID:twidi,项目名称:satchmo,代码行数:7,代码来源:tests.py
示例9: order_variable
def order_variable(order, args):
"""
Get a variable from an order
Sample usage::
{{ order|order_variable:'variable' }}
"""
args, kwargs = get_filter_args(args)
if len(args) != 1:
raise template.TemplateSyntaxError("%r filter expected only a variable, got: %s" % (args[0], args))
return order.get_variable(args[0])
开发者ID:eyeyunianto,项目名称:satchmo,代码行数:14,代码来源:satchmo_order.py
示例10: product_category_siblings
def product_category_siblings(product, args=""):
args, kwargs = get_filter_args(args,
keywords=('variations', 'include_self'),
boolargs=('variations', 'include_self'),
stripquotes=True)
sibs = product.get_category.product_set.all().order_by('ordering', 'name')
if not kwargs.get('variations', True):
sibs = [sib for sib in sibs if not sib.has_variants]
if not kwargs.get('include_self', True):
sibs = [sib for sib in sibs if not sib == product]
return sibs
开发者ID:hnejadi,项目名称:xerobis,代码行数:14,代码来源:satchmo_category.py
示例11: normalize_decimal
def normalize_decimal(value, args=""):
"""
PARTIAL UNIT ROUNDING DECIMAL
Converts a valid float, integer, or string to a decimal number with a specified
number of decimal places, performs "partial unit rounding", and decimal normalization.
Usage:
val|normalize_decimal
val|normalize_decimal:'places=2'
val|normalize_decimal:'places=2:roundfactor=.5'
val|normalize_decimal:'places=2:roundfactor=.5:normalize=False'
val
The value to be converted and optionally formated to decimal.
places
The decimal place precision is defined by integer "places" and
must be <= the precision defined in the decimal.Decimal context. roundfactor represents
the maximum number of decimal places to display if normalize is False.
roundfactor
(partial unit rounding factor) If roundfactor is between 0 and 1, roundfactor rounds up
(positive roundfactor value) or down (negative roundfactor value) in factional "roundfactor" increments.
normalize
If normalize is True (any value other than False), then rightmost zeros are truncated.
General Filter/Template Usage.
normalize_decimal is generally used without parameters in the template.
Defaults are: places=2, roundfactor=None, normalize=True
If normalize_decimal is not used as a template filter, the value (quantity)
will display the full decimal value in the template field.
"""
if value == '' or value is None:
return value
args, kwargs = get_filter_args(args,
keywords=('places','roundfactor', 'normalize'),
intargs=('places',),
boolargs=('normalize',), stripquotes=True)
if not 'places' in kwargs:
kwargs['places'] = 2
try:
return mark_safe(str(round_decimal(val=value, **kwargs)))
except RoundedDecimalError, e:
log.error("normalize_decimal error val=%s, id-%s, msg=%s", (e.val, e.id, e.msg))
return value
开发者ID:34,项目名称:T,代码行数:49,代码来源:normalize_decimal.py
示例12: order_variable
def order_variable(order, args):
"""
Get a variable from an order
Sample usage::
{{ order|order_variable:'variable' }}
"""
args, kwargs = get_filter_args(args)
args = token.split_contents()
if not len(args == 1):
raise template.TemplateSyntaxError("%r filter expected variable, got: %s" % (args[0], args))
return order.get_variable(args[0])
开发者ID:hnejadi,项目名称:xerobis,代码行数:15,代码来源:satchmo_order.py
示例13: product_count
def product_count(category, args=''):
"""Get a count of products for the base object.
If `category` is None, then count everything.
If it is a `Category` object then count everything in the category and subcategories.
"""
args, kwargs = get_filter_args(args, boolargs=('variations'))
variations = kwargs.get('variations', False)
try:
ct = keyedcache.cache_get('product_count', category, variations)
except keyedcache.NotCachedError:
if not category:
ct = Product.objects.active_by_site(variations=variations).count()
else:
ct = category.active_products(include_children=True, variations=variations).count()
keyedcache.cache_set('product_count', category, args, value=ct)
return ct
开发者ID:DrOctogon,项目名称:Satchmo,代码行数:18,代码来源:satchmo_product.py
示例14: product_images
def product_images(product, args=""):
args, kwargs = get_filter_args(args,
keywords=('include_main', 'maximum'),
boolargs=('include_main'),
intargs=('maximum'),
stripquotes=True)
q = product.productimage_set
if kwargs.get('include_main', True):
q = q.all()
else:
main = product.main_image
q = q.exclude(id = main.id)
maximum = kwargs.get('maximum', -1)
if maximum>-1:
q = list(q)[:maximum]
return q
开发者ID:DrOctogon,项目名称:Satchmo,代码行数:19,代码来源:satchmo_product.py
注:本文中的satchmo_utils.templatetags.get_filter_args函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论