From 862bafbbd3ae04765e5abbe81460933fd60389e9 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 29 Jan 2021 01:25:30 +0100 Subject: [PATCH] [Plugin] balance: Fixed transaction filter issue, fixed reverse * Filter by end now filters correctly * Reverse a transaction will now return correct reversal transaction --- flaschengeist/controller/userController.py | 12 +++--------- flaschengeist/plugins/balance/balance_controller.py | 4 ++-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/flaschengeist/controller/userController.py b/flaschengeist/controller/userController.py index 283de3d..02cfc56 100644 --- a/flaschengeist/controller/userController.py +++ b/flaschengeist/controller/userController.py @@ -47,9 +47,7 @@ def request_reset(user: User): logger.debug(f"New password reset request for {user.userid}") reset = _generate_password_reset(user) - subject = str(config["MESSAGES"]["password_subject"]).format( - name=user.display_name, username=user.userid - ) + subject = str(config["MESSAGES"]["password_subject"]).format(name=user.display_name, username=user.userid) text = str(config["MESSAGES"]["password_text"]).format( name=user.display_name, username=user.userid, @@ -158,9 +156,7 @@ def find_user(uid_mail): if user: update_user(user) else: - user = current_app.config["FG_AUTH_BACKEND"].find_user( - uid_mail, uid_mail if mail else None - ) + user = current_app.config["FG_AUTH_BACKEND"].find_user(uid_mail, uid_mail if mail else None) if user: db.session.add(user) db.session.commit() @@ -190,9 +186,7 @@ def register(data): reset = _generate_password_reset(user) - subject = str(config["MESSAGES"]["welcome_subject"]).format( - name=user.display_name, username=user.userid - ) + subject = str(config["MESSAGES"]["welcome_subject"]).format(name=user.display_name, username=user.userid) text = str(config["MESSAGES"]["welcome_text"]).format( name=user.display_name, username=user.userid, diff --git a/flaschengeist/plugins/balance/balance_controller.py b/flaschengeist/plugins/balance/balance_controller.py index e2732ce..4cf0360 100644 --- a/flaschengeist/plugins/balance/balance_controller.py +++ b/flaschengeist/plugins/balance/balance_controller.py @@ -105,7 +105,7 @@ def get_transactions(user, start=None, end=None, limit=None, offset=None): if start: query = query.filter(start <= Transaction.time) if end: - query = query.filter(Transaction.time >= end) + query = query.filter(Transaction.time <= end) query = query.order_by(Transaction.time.desc()) if offset is not None: query = query.offset(offset) @@ -124,7 +124,7 @@ def reverse_transaction(transaction: Transaction, author: User): if transaction.reversal_: raise Conflict reversal = send(transaction.receiver_, transaction.sender_, transaction.amount, author) - reversal.reversal_ = transaction + reversal.original_ = transaction transaction.reversal = reversal db.session.commit() return reversal