service.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:hreftoday 作者: soasme 项目源码 文件源码
def set_role(id, role):
    user = User.query.get(id)
    role = Role.query.filter_by(name=role).first()
    if not user:
        print 'User not found'
        exit(1)
    if not role:
        print 'Role not found'
        exit(1)
    user.roles.append(role)
    db.session.add(user)
    db.session.commit()
    print 'Role set successfully.'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号