[Plugin] balance: Added shortcuts configuration for balance

This commit is contained in:
Ferdinand Thiessen 2021-01-20 15:21:33 +01:00
parent aeadc78acc
commit f42d5956db
1 changed files with 22 additions and 1 deletions

View File

@ -4,7 +4,7 @@ Extends users plugin with balance functions
"""
from datetime import datetime, timezone
from flask import Blueprint, request
from flask import Blueprint, request, jsonify
from werkzeug.exceptions import Forbidden, BadRequest
from flaschengeist import logger
@ -39,6 +39,27 @@ class BalancePlugin(Plugin):
db.create_all()
@balance_bp.route("/users/<userid>/balance/shortcuts", methods=["GET"])
@login_required()
def get_shortcuts(userid, current_session: Session):
"""Get set limit of an user
Route: ``/users/<userid>/balance/limit`` | Method: ``GET``
Args:
userid: Userid identifying the user
current_session: Session sent with Authorization Header
Returns:
JSON object containing the limit (or Null if no limit set) or HTTP error
"""
if userid != current_session._user.userid:
raise Forbidden
user = userController.get_user(userid)
return jsonify(user.get_attribute("balance_shortcuts", [-2, -1, -0.5]))
@balance_bp.route("/users/<userid>/balance/limit", methods=["GET"])
@login_required()
def get_limit(userid, current_session: Session):