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)
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
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
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
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
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
def get(self): session = Session() exist = session.query(User).all() if not exist: abort(404, message="No one user in database") return exist
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