[Plugin] balance: Fixed transaction filter issue, fixed reverse

* Filter by end now filters correctly
* Reverse a transaction will now return correct reversal transaction
This commit is contained in:
Ferdinand Thiessen 2021-01-29 01:25:30 +01:00
parent 708a45d43c
commit 862bafbbd3
2 changed files with 5 additions and 11 deletions

View File

@ -47,9 +47,7 @@ def request_reset(user: User):
logger.debug(f"New password reset request for {user.userid}") logger.debug(f"New password reset request for {user.userid}")
reset = _generate_password_reset(user) reset = _generate_password_reset(user)
subject = str(config["MESSAGES"]["password_subject"]).format( subject = str(config["MESSAGES"]["password_subject"]).format(name=user.display_name, username=user.userid)
name=user.display_name, username=user.userid
)
text = str(config["MESSAGES"]["password_text"]).format( text = str(config["MESSAGES"]["password_text"]).format(
name=user.display_name, name=user.display_name,
username=user.userid, username=user.userid,
@ -158,9 +156,7 @@ def find_user(uid_mail):
if user: if user:
update_user(user) update_user(user)
else: else:
user = current_app.config["FG_AUTH_BACKEND"].find_user( user = current_app.config["FG_AUTH_BACKEND"].find_user(uid_mail, uid_mail if mail else None)
uid_mail, uid_mail if mail else None
)
if user: if user:
db.session.add(user) db.session.add(user)
db.session.commit() db.session.commit()
@ -190,9 +186,7 @@ def register(data):
reset = _generate_password_reset(user) reset = _generate_password_reset(user)
subject = str(config["MESSAGES"]["welcome_subject"]).format( subject = str(config["MESSAGES"]["welcome_subject"]).format(name=user.display_name, username=user.userid)
name=user.display_name, username=user.userid
)
text = str(config["MESSAGES"]["welcome_text"]).format( text = str(config["MESSAGES"]["welcome_text"]).format(
name=user.display_name, name=user.display_name,
username=user.userid, username=user.userid,

View File

@ -105,7 +105,7 @@ def get_transactions(user, start=None, end=None, limit=None, offset=None):
if start: if start:
query = query.filter(start <= Transaction.time) query = query.filter(start <= Transaction.time)
if end: if end:
query = query.filter(Transaction.time >= end) query = query.filter(Transaction.time <= end)
query = query.order_by(Transaction.time.desc()) query = query.order_by(Transaction.time.desc())
if offset is not None: if offset is not None:
query = query.offset(offset) query = query.offset(offset)
@ -124,7 +124,7 @@ def reverse_transaction(transaction: Transaction, author: User):
if transaction.reversal_: if transaction.reversal_:
raise Conflict raise Conflict
reversal = send(transaction.receiver_, transaction.sender_, transaction.amount, author) reversal = send(transaction.receiver_, transaction.sender_, transaction.amount, author)
reversal.reversal_ = transaction reversal.original_ = transaction
transaction.reversal = reversal transaction.reversal = reversal
db.session.commit() db.session.commit()
return reversal return reversal