def post(self): username = get_jwt_identity() # DataBase.change_products_quantity_in_db() DataBase.add_order(username) user_details,product_details = DataBase.get_user_details(username) MailService.send_mail_with_order_details(user_details,product_details) return make_response(response["checkout"],200)
def post(self): customer = request.form username = get_jwt_identity() name = customer['name'] mobile_number = customer['mobilenumber'] address = customer['address'] pincode = customer['pincode'] DataBase.add_to_address_db(username,name,mobile_number,address,pincode) return make_response(response["order"],200)
def get(self): user_name = get_jwt_identity() books_data = DataBase.display_wishlist(user_name) return make_response(jsonify({ "respone": books_data, "status": 200 }), 200)
def get(self): books_data = DataBase.get_books_data_from_db() return make_response( jsonify({ "response:books": books_data, "status": 200 }), 200)
def put(self): data = request.form user_name = get_jwt_identity() product_id = data['productid'] quantity = data['quantity'] books_in_cart, status_code = DataBase.update_cart( user_name, product_id, quantity) return make_response(jsonify({"respone": books_in_cart}), status_code)
def post(self): form = RegisterForm(request.form) user_name = form.username.data email = form.email.data password = form.password.data if form.validate(): return DataBase.add_user_to_db(user_name, email, password) return make_response(registration_response[400], 400)
def post(self): search_value = request.args.get('search') product_data = DataBase.search_book(search_value) if len(product_data) > 0: return make_response( jsonify({ "response:books": product_data, "status": 200 }), 200) return make_response(response['search'], 400)
def get(self): try: user_name = get_jwt_identity() if redis.exists(user_name): books_in_cart = DataBase.display_cart(user_name) return make_response( jsonify({ "respone": books_in_cart, "status": 200 }), 200) return make_response(login_response[413], 413) except ConnectionError: raise InvalidUsageError(redis_error[500], 500)
def post(self): data = request.args.get('sort') data = data.lower() if data == "lowtohigh": value = True elif data == "hightolow": value = False else: return make_response(response['sort'], 400) sorted_books = DataBase.sort_books_by_price(value) return make_response(jsonify({ "respone": sorted_books, "status": 200 }), 200)
def post(self): form = LoginForm(request.form) user_name = form.username.data password = form.password.data try: if not form.validate(): return make_response(login_response[400], 400) present_in_db, confirmed = DataBase.check_user_in_db( user_name, password) if present_in_db: if not confirmed: return make_response(login_response[411], 411) access_token = create_access_token(identity=user_name) app.logger.info('{} was logged in'.format(user_name)) redis.set(name=user_name, value=access_token) redis.expire(user_name, redis_time) return make_response( jsonify({ "respone:token": access_token, "status": 200 }), 200) return make_response(login_response[401], 401) except ConnectionError: raise InvalidUsageError(redis_error[500], 500)
def post(self): data = request.form user_name = get_jwt_identity() product_id = data['productid'] response = DataBase.add_to_wishlist(user_name, product_id) return make_response(response, 200)
def delete(self): data = request.form user_name = get_jwt_identity() product_id = data['productid'] DataBase.remove_from_cart(user_name, product_id) return make_response(response['deleted'], 200)
def post(self): data = request.form user_name = get_jwt_identity() product_id = data['productid'] return DataBase.add_to_cart(user_name, product_id)
def get(self, token): DataBase.check_token(token) return make_response(registration_response["success"], 200)