本文整理汇总了Python中autumn.torn.form.Form.expire_at['value']方法的典型用法代码示例。如果您正苦于以下问题:Python Form.expire_at['value']方法的具体用法?Python Form.expire_at['value']怎么用?Python Form.expire_at['value']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autumn.torn.form.Form
的用法示例。
在下文中一共展示了Form.expire_at['value']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import expire_at['value'] [as 别名]
def post(self):
form = Form(self.request.arguments, add_schema)
if not form.validate():
logging.error(form.errors)
self.render('wx/activity/edit.html', form=form, error='参数不正确', action='add')
return
# 添加新的微活动
fields = ('type', 'name', 'start_at', 'expire_at', 'detail', 'win_desc', 'lose_desc', 'due_desc', 'max_try',
'daily_try', 'rewards_possibility')
sql = """insert into wx_activity (%s, sp_id, created_at, deleted) values (%s, %%s, NOW(), 0)"""\
% (','.join(fields), ','.join(['%s']*len(fields)))
form.expire_at['value'] = ceiling(form.expire_at.value, today=True) if form.expire_at.value else None
params = [form.arguments[field]['value'] for field in fields]
params.extend([self.current_user.supplier_id])
activity_id = self.db.execute(sql, *params)
# 添加相关的奖品信息
r_types = self.get_arguments('rewards_type')
r_names = self.get_arguments('rewards_name')
r_nums = [int(i) for i in self.get_arguments('rewards_num')]
for i in range(len(r_types)):
rewards_id = self.db.execute('insert into wx_activity_rewards (act_id, type, name, num) values '
'(%s, %s, %s, %s)', activity_id, r_types[i], r_names[i], r_nums[i])
# 产生兑奖SN码
generate_sn(self.db, rewards_id, r_nums[i])
self.redirect(self.reverse_url('wx.activity.list'))
示例2: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import expire_at['value'] [as 别名]
def post(self):
form = Form(self.request.arguments, add_schema)
goods_info, shops, properties, img = get_goods_info(self.db, form.id.value)
if goods_info.supplier_id != self.current_user.supplier_id:
raise HTTPError(403)
if goods_info.status not in ['PREPARE', 'REJECT']:
raise HTTPError(403)
# 为了下面的 validate 成功 这里必须填入数据
form.arguments.update({'generate_type': EmptyDict({'value': goods_info.generate_type})})
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():
form.properties.value = properties
form.shops['value'] = shops
form.img_paths['value'] = img_paths
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)
logging.error(json_dumps(form.errors))
self.render('goods/add.html', form=form, error='', action='edit', supplier_shops=supplier_shops,
img_url=img_url)
fields = ('type', 'generate_type', 'expire_at', 'category_id', 'name', 'short_name', 'sms_name', 'face_value',
'sales_price', 'purchase_price', 'stock', 'virtual_sales_count', 'img_path', 'detail', 'tips',
'supplier_intro', 'all_shop', 'on_sale_at', 'off_sale_at', 'img_paths', 'postage')
update_sql = 'update goods set %s where id=%%s' % ','.join([field + '=%s' for field in 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
params = [form.arguments[field]['value'] for field in fields]
params.append(form.id.value)
self.db.execute(update_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, '商户修改了商品', form.id.value)
# 批量更新商品属性
self.db.execute('delete from goods_property where goods_id=%s and name in ("gift_card", "hidden", "ktv")',
form.id.value)
if form.properties.value:
insert_properties(self.db, form.properties.value, form.id.value)
# 批量更新关联门店
self.db.execute('delete from goods_supplier_shop where goods_id=%s', form.id.value)
if not form.all_shop.value:
if form.shops.value:
insert_shops(self.db, form.shops.value, form.id.value)
self.redirect(self.reverse_url('goods.list'))
示例3: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import expire_at['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
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'))