Ejemplo n.º 1
0
 def post(self):
     session = Session()
     args = user_put_args.parse_args()
     exist = User(username=args['username'],
                  password=hash_password(args['password']))
     session.add(exist)
     session.commit()
     return exist, 201
Ejemplo n.º 2
0
    def post(self):
        session = Session()
        args = wallets_put_args.parse_args()
        user = auth.current_user()
        user_id = user.user_id

        wallet = Wallets(user_id=user_id, name=args['name'], uah=args['uah'])
        session.add(wallet)
        session.commit()
        return wallet, 200
Ejemplo n.º 3
0
def create_wallet():
    session = Session()

    data = request.get_json()

    try:
        wallet = Wallets(**data)
    except:
        return jsonify({"Message": "Invalid input"}), 405
    #  if not "owner_uid" != User.user_id:
    #     abort(404, description="Wallet owner not found")

    session.add(wallet)
    session.commit()

    return jsonify({"Success": "Wallet has been created"}), 200
Ejemplo n.º 4
0
    def put(self):
        session = Session()
        args = user_update_args.parse_args()
        # result = session.query(User).filter_by(id=user_id).first()
        exist = auth.current_user()
        if not exist:
            abort(404, message="User doesn't exist, cannot update")
        if args['username']:
            exist.username = args['username']
        if args['password']:
            exist.password = hash_password(args['password'])

        exist = session.merge(exist)
        session.add(exist)
        session.commit()

        return exist