Ejemplo n.º 1
0
def get_wallet(user_id):
    session = Session()
    try:
        wallet = session.query(Wallets).filter_by(user_id=int(user_id)).one()
    except:
        abort(404, description="Wallet not found")
    return WalletsSchema().dump(wallet)
Ejemplo n.º 2
0
    def get(self, user_id):
        session = Session()

        user = auth.current_user()
        user_id = user.user_id
        exist = session.query(User).filter_by(user_id=user_id).first()
        if not exist:
            abort(404, message="Couldn`t find wallet with that id")
        return exist
Ejemplo n.º 3
0
    def get(self):
        session = Session()
        user = auth.current_user()
        user_id = user.user_id
        exist = session.query(Wallets).filter_by(user_id=user_id).all()
        if not exist:
            abort(404, message="No each wallet in database")

        return exist
Ejemplo n.º 4
0
def delete_wallet(user_id):
    session = Session()
    try:
        wallet = session.query(Wallets).filter_by(user_id=int(user_id)).one()
    except:
        abort(404, description="Wallet not found")

    session.delete(wallet)

    session.commit()

    return jsonify({"Success": "Wallet has been deleted"}), 200
Ejemplo n.º 5
0
def update_wallet(user_id):
    session = Session()

    try:
        wallet = session.query(Wallets).filter_by(user_id=int(user_id)).one()
    except:
        abort(404, description="Wallet not found")

    data = request.get_json()
    try:

        if data.get('name', None):
            wallet.name = data['name']

    except:
        abort(405, description="Invalid input")

    session.commit()

    return jsonify({"Success": "Wallet has been changed"}), 200
Ejemplo n.º 6
0
 def get(self, user_id):
     session = Session()
     exist = session.query(User).filter_by(user_id=user_id).first()
     if not exist:
         abort(404, message="Couldn`t find user with that id")
     return exist
Ejemplo n.º 7
0
 def get(self):
     session = Session()
     exist = session.query(User).all()
     if not exist:
         abort(404, message="No one user in database")
     return exist
Ejemplo n.º 8
0
def verify_user(username, password):
    session = Session()
    user = session.query(User).filter_by(username=username).first()
    if user and bcrypt.check_password_hash(user.password, password):
        return user