Compare commits
3 Commits
a094edf6cd
...
06b38b8231
Author | SHA1 | Date |
---|---|---|
Ferdinand Thiessen | 06b38b8231 | |
Ferdinand Thiessen | 84f085f357 | |
Ferdinand Thiessen | eaeb103e93 |
|
@ -54,8 +54,6 @@ def __load_plugins(app):
|
|||
logger.error(
|
||||
f"Plugin {entry_point.name} was enabled, but could not be loaded due to an error.", exc_info=True
|
||||
)
|
||||
del plugin
|
||||
continue
|
||||
if isinstance(plugin, AuthPlugin):
|
||||
logger.debug(f"Found authentication plugin: {entry_point.name}")
|
||||
if entry_point.name == config["FLASCHENGEIST"]["auth"]:
|
||||
|
@ -67,7 +65,6 @@ def __load_plugins(app):
|
|||
app.config["FG_PLUGINS"][entry_point.name] = plugin
|
||||
if "FG_AUTH_BACKEND" not in app.config:
|
||||
logger.error("No authentication plugin configured or authentication plugin not found")
|
||||
raise RuntimeError("No authentication plugin configured or authentication plugin not found")
|
||||
|
||||
|
||||
def install_all():
|
||||
|
|
|
@ -113,9 +113,7 @@ def get_transaction(transaction_id) -> Transaction:
|
|||
return transaction
|
||||
|
||||
|
||||
def get_transactions(
|
||||
user, start=None, end=None, limit=None, offset=None, show_reversal=False, show_cancelled=True, descending=False
|
||||
):
|
||||
def get_transactions(user, start=None, end=None, limit=None, offset=None, show_reversal=False, show_cancelled=True):
|
||||
count = None
|
||||
query = Transaction.query.filter((Transaction.sender_ == user) | (Transaction.receiver_ == user))
|
||||
if start:
|
||||
|
@ -127,10 +125,7 @@ def get_transactions(
|
|||
query = query.filter(Transaction.original_ == None)
|
||||
if not show_cancelled:
|
||||
query = query.filter(Transaction.reversal_id.is_(None))
|
||||
if descending:
|
||||
query = query.order_by(Transaction.time.desc())
|
||||
else:
|
||||
query = query.order_by(Transaction.time)
|
||||
query = query.order_by(Transaction.time)
|
||||
if limit is not None:
|
||||
count = query.count()
|
||||
query = query.limit(limit)
|
||||
|
|
|
@ -99,32 +99,6 @@ def set_limit(userid, current_session: Session):
|
|||
return HTTP.no_content()
|
||||
|
||||
|
||||
@BalancePlugin.blueprint.route("/users/balance/limit", methods=["GET", "PUT"])
|
||||
@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):
|
||||
|
@ -196,7 +170,6 @@ def get_transactions(userid, current_session: Session):
|
|||
show_cancelled = request.args.get("showCancelled", True)
|
||||
limit = request.args.get("limit")
|
||||
offset = request.args.get("offset")
|
||||
descending = request.args.get("descending", False)
|
||||
try:
|
||||
if limit is not None:
|
||||
limit = int(limit)
|
||||
|
@ -206,20 +179,11 @@ def get_transactions(userid, current_session: Session):
|
|||
show_reversals = str2bool(show_reversals)
|
||||
if not isinstance(show_cancelled, bool):
|
||||
show_cancelled = str2bool(show_cancelled)
|
||||
if not isinstance(descending, bool):
|
||||
descending = str2bool(descending)
|
||||
except ValueError:
|
||||
raise BadRequest
|
||||
|
||||
transactions, count = balance_controller.get_transactions(
|
||||
user,
|
||||
start,
|
||||
end,
|
||||
limit,
|
||||
offset,
|
||||
show_reversal=show_reversals,
|
||||
show_cancelled=show_cancelled,
|
||||
descending=descending,
|
||||
user, start, end, limit, offset, show_reversal=show_reversals, show_cancelled=show_cancelled
|
||||
)
|
||||
return {"transactions": transactions, "count": count}
|
||||
|
||||
|
|
Loading…
Reference in New Issue