Added the "accounting.utils.cast" module to cast the things to the expected type in order to supress the warnings from PyCharm.
This commit is contained in:
@ -28,6 +28,7 @@ from werkzeug.datastructures import ImmutableMultiDict
|
||||
from accounting import db
|
||||
from accounting.locale import lazy_gettext
|
||||
from accounting.models import Transaction
|
||||
from accounting.utils.cast import s
|
||||
from accounting.utils.flash_errors import flash_form_errors
|
||||
from accounting.utils.next_uri import inherit_next, or_next
|
||||
from accounting.utils.permission import has_permission, can_view, can_edit
|
||||
@ -87,7 +88,7 @@ def add_transaction(txn_type: TransactionType) -> redirect:
|
||||
form.populate_obj(txn)
|
||||
db.session.add(txn)
|
||||
db.session.commit()
|
||||
flash(lazy_gettext("The transaction is added successfully"), "success")
|
||||
flash(s(lazy_gettext("The transaction is added successfully")), "success")
|
||||
return redirect(inherit_next(__get_detail_uri(txn)))
|
||||
|
||||
|
||||
@ -141,12 +142,13 @@ def update_transaction(txn: Transaction) -> redirect:
|
||||
with db.session.no_autoflush:
|
||||
form.populate_obj(txn)
|
||||
if not form.is_modified:
|
||||
flash(lazy_gettext("The transaction was not modified."), "success")
|
||||
flash(s(lazy_gettext("The transaction was not modified.")), "success")
|
||||
return redirect(inherit_next(__get_detail_uri(txn)))
|
||||
txn.updated_by_id = get_current_user_pk()
|
||||
txn.updated_at = sa.func.now()
|
||||
db.session.commit()
|
||||
flash(lazy_gettext("The transaction is updated successfully."), "success")
|
||||
flash(s(lazy_gettext("The transaction is updated successfully.")),
|
||||
"success")
|
||||
return redirect(inherit_next(__get_detail_uri(txn)))
|
||||
|
||||
|
||||
@ -162,7 +164,8 @@ def delete_transaction(txn: Transaction) -> redirect:
|
||||
txn.delete()
|
||||
sort_transactions_in(txn.date, txn.id)
|
||||
db.session.commit()
|
||||
flash(lazy_gettext("The transaction is deleted successfully."), "success")
|
||||
flash(s(lazy_gettext("The transaction is deleted successfully.")),
|
||||
"success")
|
||||
return redirect(or_next(__get_default_page_uri()))
|
||||
|
||||
|
||||
@ -193,10 +196,10 @@ def sort_transactions(txn_date: date) -> redirect:
|
||||
form: TransactionReorderForm = TransactionReorderForm(txn_date)
|
||||
form.save_order()
|
||||
if not form.is_modified:
|
||||
flash(lazy_gettext("The order was not modified."), "success")
|
||||
flash(s(lazy_gettext("The order was not modified.")), "success")
|
||||
return redirect(or_next(__get_default_page_uri()))
|
||||
db.session.commit()
|
||||
flash(lazy_gettext("The order is updated successfully."), "success")
|
||||
flash(s(lazy_gettext("The order is updated successfully.")), "success")
|
||||
return redirect(or_next(__get_default_page_uri()))
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user