Removed the redundant post_update methods from the AccountForm and CurrencyForm forms.
This commit is contained in:
@ -19,7 +19,6 @@
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, ValidationError
|
||||
from wtforms.validators import DataRequired, Regexp, NoneOf
|
||||
@ -82,13 +81,3 @@ class CurrencyForm(FlaskForm):
|
||||
current_user_pk: int = get_current_user_pk()
|
||||
obj.created_by_id = current_user_pk
|
||||
obj.updated_by_id = current_user_pk
|
||||
|
||||
def post_update(self, obj: Currency) -> None:
|
||||
"""The post-processing after the update.
|
||||
|
||||
:param obj: The currency object.
|
||||
:return: None
|
||||
"""
|
||||
current_user_pk: int = get_current_user_pk()
|
||||
obj.updated_by_id = current_user_pk
|
||||
obj.updated_at = sa.func.now()
|
||||
|
@ -19,6 +19,7 @@
|
||||
"""
|
||||
from urllib.parse import urlencode, parse_qsl
|
||||
|
||||
import sqlalchemy as sa
|
||||
from flask import Blueprint, render_template, redirect, session, request, \
|
||||
flash, url_for
|
||||
from werkzeug.datastructures import ImmutableMultiDict
|
||||
@ -29,6 +30,7 @@ from accounting.models import Currency
|
||||
from accounting.utils.next_uri import inherit_next, or_next
|
||||
from accounting.utils.pagination import Pagination
|
||||
from accounting.utils.permission import has_permission, can_view, can_edit
|
||||
from accounting.utils.user import get_current_user_pk
|
||||
from .forms import CurrencyForm
|
||||
|
||||
bp: Blueprint = Blueprint("currency", __name__)
|
||||
@ -146,7 +148,8 @@ def update_currency(currency: Currency) -> redirect:
|
||||
flash(lazy_gettext("The currency was not modified."), "success")
|
||||
return redirect(inherit_next(url_for("accounting.currency.detail",
|
||||
currency=currency)))
|
||||
form.post_update(currency)
|
||||
currency.updated_by_id = get_current_user_pk()
|
||||
currency.updated_at = sa.func.now()
|
||||
db.session.commit()
|
||||
flash(lazy_gettext("The currency is updated successfully."), "success")
|
||||
return redirect(inherit_next(url_for("accounting.currency.detail",
|
||||
|
Reference in New Issue
Block a user