Closed Adora2401 closed 2 years ago
Hi all, I have no idea what these codes mean:
# query string arguments shopcart_args = reqparse.RequestParser() shopcart_args.add_argument('item-id', type=int, required=False, help='List shopcarts containing the item id')
` @api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()
results = [dict(shopcart) for shopcart in shopcarts]
app.logger.info("Returning %d shopcarts", len(results))
return results, status.HTTP_200_OK
`
It looks like if we pass Item-id to this function, then use Shopcart.query_by_item_id(args['item-id']) instead of the following lines. However, how to pass the item-id from front-end to back-end confuses me, I have tried to use the same way as other get in our code, unfortunately, as the difference of paras, this method not works. I will really appreciate it If anyone else could take this part or give me some ideas.
I cannot help if there are any UI/JavaScript issues but querying is called like this: GET on .../shopcarts?item-id=100 So you need to call that route in the js file. I don't know JavaScript so if you have problems with that I'll refer to someone else
Hi Yinuo, thanks for your work! I think I can try to take over this part.
Hi Yinuo, thanks for your work! I think I can try to take over this part.
If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url
Hi Yinuo, thanks for your work! I think I can try to take over this part.
If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url
Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()
results = [dict(shopcart) for shopcart in shopcarts]
app.logger.info("Returning %d shopcarts", len(results))
return results, status.HTTP_200_OK`
But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.
Hi Yinuo, thanks for your work! I think I can try to take over this part.
If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url
Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()
results = [dict(shopcart) for shopcart in shopcarts] app.logger.info("Returning %d shopcarts", len(results)) return results, status.HTTP_200_OK`
But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.
Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.
Hi Yinuo, thanks for your work! I think I can try to take over this part.
If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url
Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()
results = [dict(shopcart) for shopcart in shopcarts] app.logger.info("Returning %d shopcarts", len(results)) return results, status.HTTP_200_OK`
But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.
Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.
Hi Yinuo, thanks for your work! I think I can try to take over this part.
If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url
Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()
results = [dict(shopcart) for shopcart in shopcarts] app.logger.info("Returning %d shopcarts", len(results)) return results, status.HTTP_200_OK`
But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.
Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.
If it is not solved tonight, I am free to offer helps also.
Hi Yinuo, thanks for your work! I think I can try to take over this part.
If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url
Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()
results = [dict(shopcart) for shopcart in shopcarts] app.logger.info("Returning %d shopcarts", len(results)) return results, status.HTTP_200_OK`
But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.
Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.
Hi Yinuo, thanks for your work! I think I can try to take over this part.
If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url
Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()
results = [dict(shopcart) for shopcart in shopcarts] app.logger.info("Returning %d shopcarts", len(results)) return results, status.HTTP_200_OK`
But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.
Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.
If it is not solved tonight, I am free to offer helps also.
Hi Yuwen, I am also get stuck at this issue. Would you mind giving a hand here? Thank you!
Hi Yinuo, thanks for your work! I think I can try to take over this part.
If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url
Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()
results = [dict(shopcart) for shopcart in shopcarts] app.logger.info("Returning %d shopcarts", len(results)) return results, status.HTTP_200_OK`
But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.
Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.
Hi Yinuo, thanks for your work! I think I can try to take over this part.
If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url
Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()
results = [dict(shopcart) for shopcart in shopcarts] app.logger.info("Returning %d shopcarts", len(results)) return results, status.HTTP_200_OK`
But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.
Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.
If it is not solved tonight, I am free to offer helps also.
Hi Yuwen, I am also get stuck at this issue. Would you mind giving a hand here? Thank you!
OK, I will look at it soon.
Codecov Report
100.00% <100.00%> (ø)
Continue to review full report at Codecov.