Skip to content

Commit

Permalink
Merge pull request #24 from Lend-it/devel
Browse files Browse the repository at this point in the history
Release - 20/04/2021 - Rubik v0.12.0
  • Loading branch information
lucasdutraf authored Apr 20, 2021
2 parents 073841b + 27d29a6 commit 8cff5b2
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion project/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,39 @@ 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},
}
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 8cff5b2

Please sign in to comment.