lfs的附加准则
lfs_criterion_extra的Python项目详细描述
为基于LFS的车间添加了更多标准
安装
安装很简单
pip install lfs-criterion-extra
或
pip install git+https://github.com/suvit/lfs-criterion-extra
在安装包之后,您应该添加 lfs}$lfs应用程序之前安装的{str 1}$lfs应用程序的{str 1}$lfs\u额外标准。 这是因为,此应用程序覆盖LFS模板。
之后,您需要在db中添加表
python manage.py syncdb
就这些。
用法
lfs criterion extra修补lfs准则模块以支持新准则。 修补后,您可以使用以下几个新标准:
- orderCountCriteria
- 检查请求的已关闭订单计数。用户
- groupcriterion
- 检查请求。用户在保存的组中
- categorycriterion
- 检查购物车中的产品或产品是否在保存的类别中
- productCriteria
- 检查购物车中的产品或产品是否在保存的产品列表中
- ordercompositioncriterion
- 在购物车中检查
- 折扣标准
- 检查保存的折扣是否有效
- ordersummcriterion
- 检查关闭的订单价格总和
- manufacturercriterion
- 检查产品的制造商是否在保存的制造商列表中
- timecriterion
- 现在检查要与节省的时间进行比较的时间
- cartamount标准
- 检查购物车金额
- maxWeightCriteria
- 检查购物车中产品的最大重量
- forSaleCriterion
- 检查购物车中的产品是否出售
- manualdeliverytimecriterion
- 检查产品或购物车中的产品是否有手动交付时间
- fullusercriterion(高级用户标准)
- 增加了检查用户是否匿名的功能。
- profitcriterion(不与基本LFS一起使用,需要供应商提供价格)
- 检查产品利润
您可以从“标准”选项卡中选择新的标准 交货和付款方式。
增加了自己的标准
您可以继承criterion或numbercriterion
from lfs_criterion_extra.models import Criterion, NumberCriterion
- class FooCriterion(NumberCriterion):
foo = models.DecimalField(‘FOO’)
‘may be other model fields’
value_attr = ‘foo’ # from that attribute get value to compare content_type = ‘foo’ # internal id of the criterion name = ‘Foo’ # displayable value
- def is_valid(self, request, product=None):
- how_many_foo = product.name.count(‘foo’) return self.test_value(how_many_foo)
仅此而已,你的标准出现在标准列表中.
待办事项
- 将monkey.py移到lfs.criterian.core(合并或移到lfs 0.8)
- 编写测试