本文整理汇总了Python中autumn.torn.form.Form类的典型用法代码示例。如果您正苦于以下问题:Python Form类的具体用法?Python Form怎么用?Python Form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Form类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
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')))
示例2: post
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'))
示例3: post
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'))
示例4: post
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'))
示例5: post
def post(self):
form = Form(self.request.arguments, shop_schema)
supplier_id = form.supplier_id.value
if not form.validate():
return self.render('supplier/shop/shop.html', form=form, error='error')
supplier = self.db.get('select short_name from supplier where id = %s', supplier_id)
# 新建账户
shop_account_id = self.db.execute('insert into account set uid=0, type=2, '
'created_at=NOW(), amount=0')
fields = dict([(key, getattr(form, key).value.strip()) for key in
['name', 'area_id', 'address', 'verify_phones', 'latitude', 'longitude', 'manager_name',
'manager_mobile', 'phone', 'traffic_info']])
fields.update({
'supplier_id': supplier_id,
'account_id': shop_account_id,
'supplier_name': supplier.short_name,
})
sql = 'insert into supplier_shop set %s' % ','.join([key + '=%s' for key in fields.keys()]) + ',created_at = NOW()'
# 新建商户门店
shop_id = self.db.execute(sql, *fields.values())
#更新店铺账户uid
self.db.execute('update account set uid=%s where id= %s', shop_id, shop_account_id)
self.redirect(self.reverse_url('supplier.shop', supplier_id))
示例6: post
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"))
示例7: post
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'))
示例8: get
def get(self):
form = Form(self.request.arguments, add_schema)
form.shops.value = []
supplier_shops = self.db.query('select ss.* from supplier_shop ss where ss.supplier_id=%s',
form.supplier_id.value)
form.skus.value = []
all_sku = self.db.query('select * from sku where deleted=0 and supplier_id=%s', form.supplier_id.value)
distributors = self.db.query('select * from distributor_shop where deleted = 0')
distributor_commission = {
options.shop_id_yihaodian: 2.00,
options.shop_id_dangdang: 2.00,
options.shop_id_jingdong: 3.00,
options.shop_id_jdb: 1.00,
options.shop_id_wuba: 3.00,
options.shop_id_gaopeng: 1.25,
options.shop_id_tuangouwang: 2.50,
options.shop_id_liketuan: 2.50,
options.shop_id_uuwang: 2.50,
options.shop_id_tmall: 1.00,
options.shop_id_jibin: 2.50,
}
form.ratios.value = ['%s-%s' % (k, v) for (k, v) in distributor_commission.iteritems()]
form.img_paths['value'] = dict()
self.render('goods/add.html', form=form, supplier_shops=supplier_shops, all_sku=all_sku,
error='', action='add', distributors=distributors, img_url=img_url)
示例9: post
def post(self):
form = Form(self.request.arguments, supplier_schema)
supplier_id = self.get_argument('id')
operators = self.db.query('select * from operator where deleted = 0')
agents = self.db.query('select * from agent where deleted = 0')
if not form.validate():
return self.render('supplier/supplier.html', form=form, operators=operators, error='请检查各项输入', agents=agents)
if self.db.query('select * from supplier where domain_name=%s and id<>%s', form.domain_name.value, supplier_id):
return self.render('supplier/supplier.html', form=form, operators=operators, error='已经有商户使用此域名', agents=agents)
if not form.properties.value:
return self.render('supplier/supplier.html', form=form, operators=operators, error='请至少选择一个商家属性', agents=agents)
if form.code.value and self.db.get('select * from supplier where code = %s and id != %s', form.code.value, supplier_id):
return self.render('supplier/supplier.html', form=form, operators=operators, error='已经有商户使用此协议', agents=agents)
self.db.execute(
'update supplier set name=%s, short_name=%s,domain_name=%s,sales_id=%s,properties=%s,'
'contact=%s,agent_id=%s, code=%s where id = %s',
form.name.value.strip(), form.short_name.value.strip(), form.domain_name.value.strip(),
form.sales_id.value, ','.join(form.properties.value), form.contact.value, form.agent_id.value,
form.code.value, supplier_id)
distr_shop = self.db.get('select * from supplier_property where name="wx_shop_id" and sp_id = %s',
supplier_id)
if 'weixin' in form.properties.value and not distr_shop:
distributor_shop_id = self.db.execute('insert into distributor_shop(distributor_id, name, money_manager, '
'created_at, created_by, distributor_name, deleted) values(%s, %s, '
'"SHOP", NOW(), %s, "微信", 1)', options.distributor_id_weixin,
form.short_name.value.strip() + '微信店', '系统')
self.db.execute('insert into supplier_property(sp_id, name, value) values(%s, "wx_shop_id", %s)',
supplier_id, distributor_shop_id)
self.redirect(self.reverse_url('supplier.detail', supplier_id))
示例10: get
def get(self):
form = Form(self.request.arguments, add_schema)
form.shops['value'] = []
supplier_shops = self.db.query('select ss.* from supplier_shop ss where ss.supplier_id=%s',
self.current_user.supplier_id)
form.img_paths['value'] = dict()
self.render('goods/add.html', form=form, supplier_shops=supplier_shops, error='', action='add', img_url=img_url)
示例11: post
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
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()}))
示例13: post
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: get
def get(self):
msg_id = self.get_argument("id", 0)
msg = self.db.get(
"select * from wx_app_msg where deleted=0 and sp_id=%s and id=%s", self.current_user.supplier_id, msg_id
)
if not msg:
raise HTTPError(404)
form = Form(msg, add_schema)
form.action["value"] = "edit"
form.img_url["value"] = img_url(msg.cover)
self.render("wx/app_msg/add.html", form=form)
示例15: post
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('goods/add.html', form=form, error='error', action='add', 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', 'all_shop',
'detail', 'tips', 'supplier_intro', 'on_sale_at', 'off_sale_at', 'postage')
goods_sql = """
insert into goods(%s, supplier_id, created_by, img_paths, created_at, status)
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.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 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)
# 批量插入分销店铺佣金
insert_ratios(self.db, goods_id)
self.redirect(self.reverse_url('goods.list'))