本文整理汇总了Python中autumn.torn.form.Form.arguments['created_by']方法的典型用法代码示例。如果您正苦于以下问题:Python Form.arguments['created_by']方法的具体用法?Python Form.arguments['created_by']怎么用?Python Form.arguments['created_by']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autumn.torn.form.Form
的用法示例。
在下文中一共展示了Form.arguments['created_by']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import arguments['created_by'] [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
form.img_paths['value'] = json_dumps(img_paths)
if not form.validate():
supplier_shops = self.db.query('select ss.* from supplier_shop ss where ss.supplier_id=%s and ss.deleted=0',
form.supplier_id.value)
distributors = self.db.query('select * from distributor_shop where deleted = 0')
all_sku = self.db.query('select * from sku where deleted=0 and supplier_id=%s', form.supplier_id.value)
form.img_paths['value'] = img_paths
logging.error(json_dumps(form.errors))
return self.render('goods/add.html', form=form, error='error', action='add', img_url=img_url,
supplier_shops=supplier_shops, all_sku=all_sku, distributors=distributors)
fields = ('type', 'generate_type', 'expire_at', 'category_id', 'name', 'short_name', 'sms_name', 'img_paths',
'face_value', 'sales_price', 'purchase_price', 'stock', 'virtual_sales_count', 'img_path', 'all_shop',
'detail', 'tips', 'supplier_intro', 'created_by', 'supplier_id', 'on_sale_at', 'off_sale_at')
goods_sql = 'insert into goods(%s, created_at, status) values (%s ,NOW(), "ON_SALE")' % (
','.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.off_sale_at['value'] = ceiling(form.off_sale_at.value, today=True) if form.off_sale_at.value else None
form.arguments['created_by'] = EmptyDict({'value': self.current_user.name})
params = [form.arguments[field]['value'] for field in fields]
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 form.properties.value:
insert_properties(self.db, form.properties.value, goods_id)
# 批量插入关联的门店
if not form.all_shop.value:
if form.shops.value:
insert_shops(self.db, form.shops.value, goods_id)
# 批量插入SKU信息
if form.skus.value:
insert_skus(self.db, form.skus.value, goods_id)
# 批量插入分销店铺佣金
if form.ratios.value:
insert_ratios(self.db, form.ratios.value, goods_id)
self.redirect(self.reverse_url('goods.show_list'))