Ejemplo n.º 1
0
 def register_by_mobile(account, password, nickname):
     with db.auto_commit():
         user = User()
         user.account = account
         user.password = password
         user.nickname = nickname
         db.session.add(user)
Ejemplo n.º 2
0
 def register_by_username(username, password, nickname):
     with db.auto_commit():
         user = User()
         user.nickname = nickname
         user.username = username
         user.password = password
         db.session.add(user)
Ejemplo n.º 3
0
def add_pro_experience():
    form = ProjectExperienceForm().validate_for_api()
    with db.auto_commit():
        data = ProjectExperience()
        ss = Resume.query.filter_by(user_id=g.user.uid).first_or_404()
        data.resume_id = ss.id
        form.populate_obj(data)
        db.session.add(data)
    return jsonify({'message': '工作经历添加成功!'})
Ejemplo n.º 4
0
def update_role(id):
    """
    用户关联用户组
    """
    form = RoleGroupForm().validate_for_api()
    with db.auto_commit():
        data = User.query.filter_by(id=id).first()
        data.role_id = form.role.data
        db.session.add(data)
    return Success(message="用户组修改成功!")
Ejemplo n.º 5
0
def role_add():
    """
    添加角色
    """
    form = RoleForm().validate_for_api()
    with db.auto_commit():
        data = Role()
        data.name = form.name.data
        data.auths = form.auths.data
        db.session.add(data)
    return Success(message="角色添加成功!")
Ejemplo n.º 6
0
 def reset_password(token, new_password):
     s = Serializer(current_app.config['SECRET_KEY'])
     try:
         data = s.loads(token.encode('utf-8'))
     except:
         return False
     uid = data.get('id')
     with db.auto_commit():
         user = User.query.get(uid)
         user.password = new_password
     return True
Ejemplo n.º 7
0
 def change_password(old_password, new_password):
     """
     修改密码
     """
     uid = g.user.uid
     with db.auto_commit():
         user = User.query.get(uid)
         if not user:
             return False
         if user.check_password(old_password):
             user.password = new_password
             return True
         return False
Ejemplo n.º 8
0
 def generate_menu(user_id, menu_id):
     with db.auto_commit():
         menu = ShoppingCart.query.filter_by(menu_id=menu_id).first()
         if menu:
             menu.num += 1
         cart = ShoppingCart()
         cart.menu_id = menu_id
         cart.user_id = user_id
         db.session.add(cart)
         # order_item_info = ShoppingCart.query.filter_by(order_item_id=mid).first_or_404()
         # order_item_info.name = menu_info_list.name
         # order_item_info.price = menu_info_list.price
         # order_item_info.num = menu_info_list.num
         # db.session.add(order_item_info)
         return 'Success'
Ejemplo n.º 9
0
def add_resume():
    data = Resume()
    with db.auto_commit():
        data.user_id = g.user.uid
        db.session.add(data)
    return jsonify({'message': '可以创建简历了'})