本文整理汇总了Python中autumn.torn.form.Form.arguments['purchase_price']['value']方法的典型用法代码示例。如果您正苦于以下问题:Python Form.arguments['purchase_price']['value']方法的具体用法?Python Form.arguments['purchase_price']['value']怎么用?Python Form.arguments['purchase_price']['value']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autumn.torn.form.Form
的用法示例。
在下文中一共展示了Form.arguments['purchase_price']['value']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import arguments['purchase_price']['value'] [as 别名]
def post(self):
form = Form(self.request.arguments, add_schema)
img_paths = dict()
for key in self.request.arguments:
if key.startswith('var_img_path_'):
v = self.request.arguments[key][0]
if v:
img_paths[key[key.rindex('_')+1:]] = v
if not form.validate():
supplier_shops = self.db.query('select ss.* from supplier_shop ss where ss.supplier_id=%s and ss.deleted=0',
self.current_user.supplier_id)
form.img_paths['value'] = img_paths
logging.error(json_dumps(form.errors))
return self.render('wx/mall/goods_add.html', form=form, error='error', action='add', supplier_shops=supplier_shops,
img_url=img_url)
# 获取微信商品手续费
commission = self.db.get('select value from supplier_property where sp_id=%s and name="wx_commission"',
self.current_user.supplier_id)
if not commission:
rate = Decimal((100 - options.wx_min_commission)/100.0)
else:
rate = Decimal((100 - int(commission.value))/100.0)
# 更新结算价
form.arguments['purchase_price']['value'] = form.arguments['sales_price']['value'] * rate
fields = ('type', 'generate_type', 'expire_at', 'category_id', 'short_name', 'sms_name',
'max_buy', 'on_sale_at', 'off_sale_at', 'face_value', 'sales_price', 'purchase_price',
'stock', 'img_path', 'all_shop', 'detail', 'postage')
goods_sql = """
insert into goods(%s, supplier_id, created_by, img_paths, created_at, status, name)
values (%s, %%s, %%s, %%s, NOW(), "PREPARE", "")""" % (','.join(fields), ','.join(['%s']*len(fields)))
form.expire_at['value'] = ceiling(form.expire_at.value, today=True) if form.expire_at.value else None
form.on_sale_at['value'] = form.on_sale_at.value if form.off_sale_at.value else None
form.off_sale_at['value'] = ceiling(form.off_sale_at.value, today=True) if form.off_sale_at.value else None
params = [form.arguments[field]['value'] for field in fields]
params.extend([self.current_user.supplier_id, self.current_user.name, json_dumps(img_paths)])
goods_id = self.db.execute_lastrowid(goods_sql, * params)
self.db.execute('insert into journal(created_at, type, created_by, message, iid) '
'values(NOW(), 3, %s, %s, %s)', self.current_user.name, '商户新增了微商城商品', goods_id)
# 批量插入关联的门店
if not form.all_shop.value:
if form.shops.value:
insert_shops(self.db, form.shops.value, goods_id)
# 插入微信商品特有属性
self.db.execute('insert into goods_property (goods_id, name, value) values '
'(%s, "is_wx_goods", %s)', goods_id, "1")
self.db.execute('insert into goods_property (goods_id, name, value) values '
'(%s, "is_wx_on_sale", %s)', goods_id, "0")
self.redirect(self.reverse_url('wx.goods.list'))