本文整理汇总了Python中models.Group.add_group_member方法的典型用法代码示例。如果您正苦于以下问题:Python Group.add_group_member方法的具体用法?Python Group.add_group_member怎么用?Python Group.add_group_member使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Group
的用法示例。
在下文中一共展示了Group.add_group_member方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store_seller_post
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import add_group_member [as 别名]
def store_seller_post(store_id):
"""
store 添加商店人员
"""
db = g._imdb
developer_id = session['user']['id']
form = request.form
name = form.get('name', '')
password = form.get('password', '')
number = form.get('number', '')
if not name or not password or not store_id:
return INVALID_PARAM()
if not number:
number = None
password = md5.new(password).hexdigest()
group_id = Store.get_store_gid(db, store_id)
db.begin()
seller_id = Seller.add_seller(db, name, password, store_id, group_id, number)
Group.add_group_member(db, group_id, seller_id)
db.commit()
content = "%d,%d"%(group_id, seller_id)
publish_message(g.im_rds, "group_member_add", content)
return redirect(url_for('.store_seller', store_id=store_id))
示例2: add_seller
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import add_group_member [as 别名]
def add_seller(store_id):
rds = g.im_rds
db = g._imdb
form = request.form
name = form.get('name', '')
password = form.get('password', '')
md5_password = form.get('md5_password', '')
salt = form.get('salt', '')
number = form.get('number', '')
is_password_empty = not password and (not md5_password or not salt)
if not name or is_password_empty or not store_id:
return INVALID_PARAM()
if not number:
number = None
if password:
password = generate_password_hash(password)
elif md5_password:
password = "%s:%s"%(salt,md5_password)
logging.debug("seller name:%s number:%s password md5:%s", name, number, md5_password)
group_id = Store.get_store_gid(db, store_id)
db.begin()
seller_id = Seller.add_seller(db, name, password, store_id, number)
if group_id:
Group.add_group_member(db, group_id, seller_id)
db.commit()
Store.add_seller_id(rds, store_id, seller_id)
if group_id:
content = "%d,%d"%(group_id, seller_id)
publish_message(g.im_rds, "group_member_add", content)
obj = {"seller_id":seller_id}
return make_response(200, obj)