Compare commits

...

5 Commits

9 changed files with 16 additions and 14 deletions

View File

@ -73,7 +73,7 @@ def init_app(app: Flask, user_utils: AbstractUserUtils,
from . import currency
currency.init_app(app, bp)
from .utils import next_url
next_url.init_app(bp)
from .utils import next_uri
next_uri.init_app(bp)
app.register_blueprint(bp)

View File

@ -96,9 +96,10 @@ class AccountForm(FlaskForm):
setattr(self, "__post_update",
lambda: sort_accounts_in(prev_base_code, obj.id))
def post_update(self, obj) -> None:
def post_update(self, obj: Account) -> None:
"""The post-processing after the update.
:param obj: The account object.
:return: None
"""
current_user_pk: int = get_current_user_pk()

View File

@ -26,10 +26,11 @@ from werkzeug.datastructures import ImmutableMultiDict
from accounting import db
from accounting.locale import lazy_gettext
from accounting.models import Account, BaseAccount
from accounting.utils.next_url import inherit_next, or_next
from accounting.utils.next_uri import inherit_next, or_next
from accounting.utils.pagination import Pagination
from accounting.utils.permission import can_view, has_permission, can_edit
from .forms import AccountForm, sort_accounts_in, AccountReorderForm
from .query import get_account_query
bp: Blueprint = Blueprint("account", __name__)
"""The view blueprint for the account management."""
@ -42,7 +43,6 @@ def list_accounts() -> str:
:return: The account list.
"""
from .query import get_account_query
accounts: list[BaseAccount] = get_account_query()
pagination: Pagination = Pagination[BaseAccount](accounts)
return render_template("accounting/account/list.html",

View File

@ -83,9 +83,10 @@ class CurrencyForm(FlaskForm):
obj.created_by_id = current_user_pk
obj.updated_by_id = current_user_pk
def post_update(self, obj) -> None:
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()

View File

@ -26,7 +26,7 @@ from werkzeug.datastructures import ImmutableMultiDict
from accounting import db
from accounting.locale import lazy_gettext
from accounting.models import Currency
from accounting.utils.next_url import inherit_next, or_next
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 .forms import CurrencyForm

View File

@ -14,7 +14,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The utilities to handle the next URL.
"""The utilities to handle the next URI.
This module should not import any other module from the application.
@ -68,7 +68,7 @@ def __set_next(uri: str, next_uri: str) -> str:
"""
uri_p: ParseResult = urlparse(uri)
params: list[tuple[str, str]] = parse_qsl(uri_p.query)
params = [x for x in params if x[0] == "next"]
params = [x for x in params if x[0] != "next"]
params.append(("next", next_uri))
parts: list[str] = list(uri_p)
parts[4] = urlencode(params)

View File

@ -517,8 +517,8 @@ class AccountTestCase(unittest.TestCase):
with self.app.app_context():
cash_account: Account = Account.find_by_code(cash.code)
self.assertIsNotNone(cash_account)
self.assertNotEqual(cash_account.created_at,
cash_account.updated_at)
self.assertLess(cash_account.created_at,
cash_account.updated_at)
def test_created_updated_by(self) -> None:
"""Tests the created-by and updated-by record.

View File

@ -463,8 +463,8 @@ class CurrencyTestCase(unittest.TestCase):
with self.app.app_context():
zza_currency: Currency = db.session.get(Currency, zza.code)
self.assertIsNotNone(zza_currency)
self.assertNotEqual(zza_currency.created_at,
zza_currency.updated_at)
self.assertLess(zza_currency.created_at,
zza_currency.updated_at)
def test_created_updated_by(self) -> None:
"""Tests the created-by and updated-by record.

View File

@ -23,7 +23,7 @@ from urllib.parse import quote_plus
import httpx
from flask import Flask, request
from accounting.utils.next_url import append_next, inherit_next, or_next
from accounting.utils.next_uri import append_next, inherit_next, or_next
from accounting.utils.pagination import Pagination, DEFAULT_PAGE_SIZE
from accounting.utils.query import parse_query_keywords
from test_site import create_app, csrf