Skip to content

Commit

Permalink
Merge pull request #23 from Lend-it/133_deletar_lend
Browse files Browse the repository at this point in the history
Solve #133 Deletar Lend
  • Loading branch information
lucasdutraf authored Apr 20, 2021
2 parents 0ca6770 + 0ba7d9e commit 27d29a6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions project/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,29 @@ def get_all_request():
return jsonify(response), 200


@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 = [
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": get_category_name(available_requests)},
}
return jsonify(response), 200


@request_blueprint.route("/requests/<productcategoryid>", methods=["GET"])
def get_filtered_request(productcategoryid):
requests = get_category_name(
Expand Down

0 comments on commit 27d29a6

Please sign in to comment.