示例#1
0
def user_create():
    obj = User()
    obj.mass_assign(request.json)
    if not obj.is_valid:
        return jsonify(errors=obj.validation_errors), 422
    if request.json.get('password', '') not in ['', None]:
        obj.password = encrypt_password(request.json['password'])
    db.session.add(obj)
    db.session.commit()
    return jsonify(**obj.to_dict())
示例#2
0
def user_create():
    obj = User()
    obj.mass_assign(request.json)
    if not obj.is_valid:
        return jsonify(errors=obj.validation_errors), 422
    if request.json.get('password', '') not in ['', None]:
        obj.password = encrypt_password(request.json['password'])
    db.session.add(obj)
    db.session.commit()
    return jsonify(**obj.to_dict())
示例#3
0
def users_list():
    ary = User.all()
    return jsonarify(ary)
示例#4
0
def users_list():
    ary = User.all()
    return jsonarify(ary)