本文整理汇总了Python中autumn.torn.form.Form.validate方法的典型用法代码示例。如果您正苦于以下问题:Python Form.validate方法的具体用法?Python Form.validate怎么用?Python Form.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autumn.torn.form.Form
的用法示例。
在下文中一共展示了Form.validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self):
form = Form(self.request.arguments, shop_schema)
if not form.validate():
return self.render("distributor/shop.html", form=form, error="error")
if form.url.value:
form.url.value = form.url.value.lower()
if not re.match(r"https?", form.url.value):
form.url.value = "http://" + form.url.value
distributor_id = self.get_argument("distributor-id")
distributor = self.db.get("select name from distributor where id = %s", distributor_id)
# 新建分销商铺
shop_id = self.db.execute_lastrowid(
"insert into distributor_shop (distributor_id,name,taobao_nick,money_manager,"
"url,distributor_name,created_at,created_by) values (%s,%s,%s,%s,%s,%s,now(),%s)",
distributor_id,
form.name.value.strip(),
form.taobao_nick.value.strip(),
form.money_manager.value,
form.url.value,
distributor.name,
self.current_user.name,
)
self.redirect(url_concat(self.reverse_url("distributor.show_shop_list"), {"distributor_id": distributor_id}))
示例2: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self):
form = Form(self.request.arguments, add_list)
form.action.value = 'add'
sid = self.get_argument('supplier_id')
shop_list = self.db.query('select id, name from supplier_shop where deleted =0 and supplier_id = %s', sid)
supplier = self.db.get('select * from supplier where id = %s', sid)
if not form.validate():
return self.render('supplier/user/user.html', form=form, shop_list=shop_list, supplier=supplier)
#判断用户名和工号是否存在,同一商户的操作员登录名不能相同,如存在则返回
if self.db.query('select * from supplier_user where login_name = %s and supplier_id = %s',
form.login_name.value, sid):
form.login_name.error = u'用户名已存在,请重新输入'
return self.render('supplier/user/user.html', form=form, shop_list=shop_list, supplier=supplier)
max_message_id = self.db.get('select id from notification order by id desc limit 1').id
#生成密码的盐
password_salt = ''.join(random.sample(string.ascii_letters + string.digits, 6))
en_password = hashlib.new('md5', '123456' + password_salt).hexdigest().lower()
fields = {
'login_name': form.login_name.value.strip(),
'password': en_password,
'pwd_salt': password_salt,
'supplier_id': sid,
'name': form.name.value.strip(),
'roles': form.roles.value.strip(),
'shop_id': form.shop_id.value,
'max_message_id': max_message_id,
}
sql = 'insert into supplier_user set last_login=NOW(), created_at=NOW(), ' + '=%s,'.join(fields.keys()) + '=%s'
self.db.execute(sql, *fields.values())
self.redirect(self.reverse_url('supplier.user', self.get_argument('supplier_id')))
示例3: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [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'))
示例4: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self):
form = Form(self.request.arguments, add_edit_list)
form.action.value = 'add'
sid = self.current_user.supplier_id
shop_list = self.db.query('select id, name from supplier_shop where supplier_id = %s', sid)
supplier = self.db.get('select id supplier_id,short_name,separate_account from supplier where id = %s', sid)
form.supplier.value = supplier.short_name
if not form.validate():
self.render('shop/accounts.html', form=form, shop_list=shop_list, role='clerk', user=self.current_user)
return
#判断用户名和工号是否存在,同一商户的操作员登录名不能相同,如存在则返回
is_login_name_exist = self.db.query('select * from supplier_user where login_name = %s and supplier_id = %s',
form.login_name.value, sid)
role = self.get_argument('role')
if is_login_name_exist:
form.login_name.error = u'用户名已存在,请重新输入'
self.render('shop/accounts.html', form=form, shop_list=shop_list, role=role, user=self.current_user)
return
shop_id = self.get_argument('shop_id')
#生成密码的盐
password_salt = ''.join(random.sample(string.ascii_letters + string.digits, 6))
en_password = hashlib.new('md5', form.password.value + password_salt).hexdigest().lower()
max_message_id = self.db.get('select id from notification order by id desc limit 1').id
self.db.execute('insert into supplier_user(login_name, password, supplier_id, pwd_salt, name, '
'last_login, created_at, roles, shop_id, max_message_id) '
'values(%s, %s, %s, %s, %s, NOW(),NOW(), %s, %s, %s)',
form.login_name.value, en_password, sid, password_salt, form.name.value,
role, shop_id, max_message_id)
self.redirect(self.reverse_url('accounts.show'))
示例5: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self):
form = Form(self.request.arguments, add_schema)
role_ids = self.get_arguments('roles')
if not role_ids:
return self.render('operator/user.html', form=form)
roles = ','.join(role_ids)
if not form.validate():
return self.render('operator/user.html', form=form)
#判断用户名和工号是否存在,如存在则返回
is_login_name_exist = self.db.query('select * from operator where login_name = %s ', form.login_name.value)
if is_login_name_exist:
form.login_name.error = u'用户名已存在,请重新输入'
return self.render('operator/user.html', form=form)
#生成密码的盐
password_salt = ''.join(random.sample(string.ascii_letters + string.digits, 6))
en_password = hashlib.new('md5', form.password.value + password_salt).hexdigest().lower()
self.db.execute('insert into operator(login_name, password, pwd_salt, name, email, roles,'
'deleted, created_at, last_active) values(%s, %s, %s, %s, %s, %s, 0, NOW(), NOW())',
form.login_name.value.strip(), en_password, password_salt, form.name.value,
form.email.value.strip(), roles)
self.redirect("/operator")
示例6: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self):
form = Form(self.request.arguments, agent)
form.action.value = 'add'
if not form.validate():
sales = self.db.query('select id, name from operator where deleted = 0')
self.render('agent/agent.html', form=form, sales=sales)
return
user = self.db.get('select * from agent where deleted = 0 and username = %s', form.username.value)
if user:
form.username.error = '已存在该登录名,请更改'
sales = self.db.query('select id, name from operator where deleted = 0')
self.render('agent/agent.html', form=form, sales=sales)
return
field = ('name', 'short_name', 'sales_id', 'contact', 'type', 'mobile', 'username', 'password',
'bank_account', 'bank_head', 'bank_branch', 'bank_holder', 'bank_city')
#生成密码的盐
password_salt = ''.join(random.sample(string.ascii_letters + string.digits, 6))
form.password.value = hashlib.new('md5', form.password.value + password_salt).hexdigest().lower()
sql = 'insert into agent set %s' % ','.join([key + '= %s' for key in field])
params = [form.arguments.get(item).value for item in field]
sql += ', pwd_salt = %s, created_at = NOW(), created_by = %s'
params.append(password_salt)
params.append(self.current_user.name)
uid = self.db.execute(sql, *params)
#新建代理商的account_id
self.db.execute('insert into account(uid, type, amount, created_at) values(%s, 3, 0, NOW())', uid)
self.redirect(self.reverse_url('agent.list'))
示例7: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self):
form = Form(self.request.arguments, add_edit_list)
form.action.value = "add"
if not form.validate():
return self.render("shop/add_edit.html", form=form)
# 新建账户
shop_account_id = self.db.execute(
"insert into account(uid, type, created_at, amount) " "values(0, 2, NOW(), 0)"
)
shop_id = self.db.execute(
"insert into supplier_shop(supplier_id, name, area_id, address, account_id, manager_mobile, manager_name, "
"phone, verify_phones, traffic_info, created_at, created_by, supplier_name, longitude, latitude) "
"values(%s, %s, %s, %s, %s,%s, %s, %s, %s, %s, NOW(), %s, %s, %s, %s)",
self.current_user.supplier_id,
form.name.value,
form.area_id.value,
form.address.value,
shop_account_id,
form.manager_mobile.value,
form.manager_name.value,
form.telephone.value,
form.verify.value,
form.traffic.value,
self.current_user.name,
self.current_user.supplier_short_name,
form.longitude.value,
form.latitude.value,
)
self.db.execute("update account set uid = %s where id = %s", shop_id, shop_account_id)
self.redirect(self.reverse_url("shop.show"))
示例8: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self):
form = Form(self.request.arguments, add_schema)
if not form.validate():
return self.render('supplier/fee_add.html', form=form)
#是否有该用户
supplier = self.db.get('select id from supplier where short_name = %s', form.supplier.value)
if supplier is None:
form.supplier.error = u'没有该用户,请修改'
return self.render('supplier/fee_add.html', form=form)
#执行语句中的deleted默认为0,返回当前广告费id
trade_id = self.db.execute('insert into supplier_ads_fee(supplier_id, fee, created_at, deleted, received_at,'
'type, remark) values(%s, %s, NOW(), 0, %s, %s, %s)',
supplier.id, form.fee.value, form.received_at.value,
form.received_type.value, form.remark.value)
#将该广告费加入对应销售的帐下
account_sequence_remark = '添加广告费'
self.db.execute('insert into account_sequence(type, account_id, trade_id, trade_type, created_at, amount, '
'remark) values("SUPPLIER_ADS_FEE", 3, %s, "ADS_FEE", NOW(), %s, %s)', trade_id,
form.fee.value, account_sequence_remark)
# 记录订单日志
self.db.execute('insert into journal (created_at, type, created_by, message, iid)'
'values (NOW(), 5, %s, %s, %s)',
self.current_user.name, "广告费添加 fee_id:%s" % trade_id,
trade_id)
self.redirect(self.reverse_url('supplier.show_ads_fee'))
示例9: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [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'))
示例10: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self):
form = Form(self.request.arguments, news_schema)
if not form.validate():
return self.render('seewi/news.html', form=form, error='error')
self.db.execute('update news set title= %s, content = %s where id = %s',
form.title.value.strip(), form.content.value.strip(), form.id.value.strip())
self.redirect(url_concat(self.reverse_url('seewi.news.show_list'), {'id': form.id.value.strip()}))
示例11: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self):
form = Form(self.request.arguments, add_list)
form.action.value = 'edit'
if not form.validate():
return self.render('real/sku.html', form=form, id=self.get_argument('id'))
self.db.execute('update sku set name = %s, price = %s where id = %s',
form.name.value, form.price.value, self.get_argument('id'))
self.redirect(self.reverse_url('real.show_sku'))
示例12: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [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'))
示例13: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self, cid):
form = Form(self.request.arguments, schema)
form.action.value = 'edit'
if not form.validate():
agent = self.db.get('select id, name, short_name from agent where id = %s', self.get_argument('agent_id'))
self.render('agent/contract/contract.html', form=form, agent=agent)
return
self.db.execute('update contract set start_at = %s, expire_at = %s, remark = %s '
'where id = %s and type = 2', form.start_at.value, form.expire_at.value, form.remark.value, cid)
self.redirect(self.reverse_url('agent.contract.upload', cid))
示例14: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self, ktv_product_id):
form = Form(self.request.arguments, add_edit_list)
if not form.validate():
return self.redirect(self.reverse_url("supplier.edit_ktv", ktv_product_id))
self.db.execute(
"update ktv_product set name = %s, duration = %s, " "where id = %s",
form.name.value,
form.duration.value,
self.current_user.name,
ktv_product_id,
)
ktv_product = self.db.get("select * from ktv_product where id=%s", ktv_product_id)
self.redirect(self.reverse_url("supplier.ktv", ktv_product.supplier_id))
示例15: post
# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import validate [as 别名]
def post(self):
form = Form(self.request.arguments, add_schema)
if not form.validate():
self.render("wx/app_msg/add.html", form=form)
return
self.db.execute(
"insert into wx_app_msg(sp_id, title, author, cover, summary, content, created_at) "
"values (%s, %s, %s, %s, %s, %s, NOW())",
self.current_user.supplier_id,
form.title.value,
form.author.value,
form.cover.value,
form.summary.value,
form.content.value,
)
self.redirect(self.reverse_url("weixin.app_msg"))