feature/balance #13

Merged
ferfissimo merged 4 commits from feature/balance into develop 2021-08-09 10:06:54 +00:00
1 changed files with 26 additions and 0 deletions
Showing only changes of commit 394eef2a9e - Show all commits

View File

@ -99,6 +99,32 @@ def set_limit(userid, current_session: Session):
return HTTP.no_content()
@BalancePlugin.blueprint.route("/users/balance/limit", methods=["GET", "PUT"])
Review

Not sure how I think about that API.
Not a friend of multiple API endpoints for quite the same task (changing the limit of an user).
But on the other hand the current enpoint requires you to send N requests (for N users)...

Not sure how I think about that API. Not a friend of multiple API endpoints for quite the same task (changing the limit of an user). But on the other hand the current enpoint requires you to send N requests (for N users)...
@login_required(permission=permissions.SET_LIMIT)
def limits(current_session: Session):
"""Get, Modify limit of all users
Args:
current_ession: Session sent with Authorization Header
Returns:
JSON encoded array of userid with limit or HTTP-error
"""
users = userController.get_users()
if request.method == "GET":
return jsonify([{"userid": user.userid, "limit": user.get_attribute("balance_limit")} for user in users])
data = request.get_json()
try:
limit = data["limit"]
except (TypeError, KeyError):
raise BadRequest
for user in users:
balance_controller.set_limit(user, limit)
return HTTP.no_content()
@BalancePlugin.blueprint.route("/users/<userid>/balance", methods=["GET"])
@login_required(permission=permissions.SHOW)
def get_balance(userid, current_session: Session):