From 299ab923e0fd42bb7ea96a17488c636c9428fb90 Mon Sep 17 00:00:00 2001 From: Matheus Afonso Date: Fri, 16 Apr 2021 13:55:03 -0300 Subject: [PATCH 1/6] fix: fga-eps-mds/2020.2-Lend.it#132 return only lender null on get all Co-authored-by: Thiago Mesquita --- project/api/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/api/views.py b/project/api/views.py index b82e797..789cd4d 100755 --- a/project/api/views.py +++ b/project/api/views.py @@ -80,7 +80,7 @@ def get_all_request(): } return jsonify(response), 200 - requests = get_category_name([request.to_json() for request in Request.query.all()]) + requests = get_category_name([request.to_json() for request in Request.query.filter_by(lender=None)]) response = { "status": "success", "data": {"requests": requests}, From 5d78db146863b0b7898ba24fdf4daec0811f0549 Mon Sep 17 00:00:00 2001 From: Matheus Afonso Date: Fri, 16 Apr 2021 13:55:03 -0300 Subject: [PATCH 2/6] fix: fga-eps-mds/2020.2-Lend.it#132 return only lender null on get all Co-authored-by: Thiago Mesquita --- project/api/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/project/api/views.py b/project/api/views.py index b82e797..c0915be 100755 --- a/project/api/views.py +++ b/project/api/views.py @@ -80,7 +80,9 @@ def get_all_request(): } return jsonify(response), 200 - requests = get_category_name([request.to_json() for request in Request.query.all()]) + requests = get_category_name( + [request.to_json() for request in Request.query.filter_by(lender=None)] + ) response = { "status": "success", "data": {"requests": requests}, From fa13fc1e4ba8e15f5c5cd43048ca9c48f18071a3 Mon Sep 17 00:00:00 2001 From: Matheus Afonso Date: Fri, 16 Apr 2021 13:59:04 -0300 Subject: [PATCH 3/6] fix: fga-eps-mds/2020.2-Lend.it#132 fixed merge error on file Co-authored-by: Thiago Mesquita --- project/api/views.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/project/api/views.py b/project/api/views.py index 90fd291..c0915be 100755 --- a/project/api/views.py +++ b/project/api/views.py @@ -80,13 +80,9 @@ def get_all_request(): } return jsonify(response), 200 -<<<<<<< HEAD requests = get_category_name( [request.to_json() for request in Request.query.filter_by(lender=None)] ) -======= - requests = get_category_name([request.to_json() for request in Request.query.filter_by(lender=None)]) ->>>>>>> 299ab923e0fd42bb7ea96a17488c636c9428fb90 response = { "status": "success", "data": {"requests": requests}, From 07c8462ca7c4f8cc945e78cf04e50b56c4e7a1f9 Mon Sep 17 00:00:00 2001 From: Thais-ra Date: Fri, 16 Apr 2021 20:28:29 -0300 Subject: [PATCH 4/6] feat: fga-eps-mds/2020.2-Lend.it#133 Created route to get available requests --- project/api/views.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/project/api/views.py b/project/api/views.py index c0915be..75798c1 100755 --- a/project/api/views.py +++ b/project/api/views.py @@ -90,6 +90,27 @@ def get_all_request(): return jsonify(response), 200 +@request_blueprint.route("/requests/", methods=["GET"]) +def get_all_available_requests(usermail): + error_response = {"status": "fail", "message": "Request not found"} + + available_requests = [ + request.to_json() + for request in Request.query.filter( + Request.lender == None, Request.requester != usermail + ).all() + ] + + if not available_requests: + return jsonify(error_response), 404 + + response = { + "status": "success", + "data": {"available requests": available_requests}, + } + return jsonify(response), 200 + + @request_blueprint.route("/requests/", methods=["GET"]) def get_filtered_request(productcategoryid): requests = get_category_name( From b61c6bc13e9dc2befb26068145335f3685335cf1 Mon Sep 17 00:00:00 2001 From: Thais-ra Date: Fri, 16 Apr 2021 23:45:17 -0300 Subject: [PATCH 5/6] feat: fga-eps-mds/2020.2-Lend.it#133 Created route to get available requests --- project/api/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/api/views.py b/project/api/views.py index 75798c1..5468865 100755 --- a/project/api/views.py +++ b/project/api/views.py @@ -90,7 +90,7 @@ def get_all_request(): return jsonify(response), 200 -@request_blueprint.route("/requests/", methods=["GET"]) +@request_blueprint.route("/requests/available/", methods=["GET"]) def get_all_available_requests(usermail): error_response = {"status": "fail", "message": "Request not found"} @@ -106,7 +106,7 @@ def get_all_available_requests(usermail): response = { "status": "success", - "data": {"available requests": available_requests}, + "data": {"available_requests": available_requests}, } return jsonify(response), 200 From 0ba7d9e25f33fe601fd94f8f72310fedb865596e Mon Sep 17 00:00:00 2001 From: Thais-ra Date: Sat, 17 Apr 2021 17:20:18 -0300 Subject: [PATCH 6/6] feat: fga-eps-mds/2020.2-Lend.it#133 Changed route apperance --- project/api/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/project/api/views.py b/project/api/views.py index 5468865..b6481f4 100755 --- a/project/api/views.py +++ b/project/api/views.py @@ -90,8 +90,10 @@ def get_all_request(): return jsonify(response), 200 -@request_blueprint.route("/requests/available/", methods=["GET"]) -def get_all_available_requests(usermail): +@request_blueprint.route("/requests/available", methods=["GET"]) +def get_all_available_requests(): + usermail = request.args.get("usermail") + error_response = {"status": "fail", "message": "Request not found"} available_requests = [ @@ -106,7 +108,7 @@ def get_all_available_requests(usermail): response = { "status": "success", - "data": {"available_requests": available_requests}, + "data": {"available requests": get_category_name(available_requests)}, } return jsonify(response), 200