Exemplo n.º 1
0
def update(user_id):
    parameters = request.json

    user = User.query.get(user_id)

    user.name = parameters['name']
    user.salt = parameters['salt']
    user.email = parameters['email']
    user.password = parameters['password']
    user.registration = parameters['registration']
    user.user_type_id = parameters['user_type_id']

    db.session.commit()
    return user_schema.jsonify(user)
Exemplo n.º 2
0
def add():
    parameters = request.json

    name = parameters['name']
    salt = parameters['salt']
    email = parameters['email']
    password = parameters['password']
    registration = parameters['registration']
    user_type_id = parameters['user_type_id']

    new_user = User(registration, name, email, password, salt, user_type_id)

    db.session.add(new_user)
    db.session.commit()
    return user_schema.jsonify(new_user)
Exemplo n.º 3
0
def register():
    parameters = request.json

    e_mail = parameters['e_mail']

    if fetch_user(e_mail):
        return LOGIN_ALREADY_EXISTS, 403

    name = parameters['name']
    salt = parameters['salt']
    password = parameters['password']
    registration = parameters['registration']

    if len(registration) == 11:
        user_type_id = 1
    else:
        user_type_id = 2

    new_user = User(registration, name, e_mail, password, salt, user_type_id)

    db.session.add(new_user)
    db.session.commit()
    return user_schema.jsonify(new_user), 200
Exemplo n.º 4
0
def get_by_registration(registration):
    user = User.query.filter_by(registration=registration).first()
    return user_schema.jsonify(user)
Exemplo n.º 5
0
def get_by_email(email):
    user = User.query.filter_by(email=email).first()
    return user_schema.jsonify(user)
Exemplo n.º 6
0
def get(user_id):
    return user_schema.jsonify(User.query.get(user_id))