Compare commits

..

No commits in common. "d9c08568cf9848078b6ac8b3d48fb3a4be10f22f" and "2ab60b2224179e650b9ee2ed1e37a264f66e10ce" have entirely different histories.

9 changed files with 14 additions and 16 deletions

View File

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

View File

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

View File

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

View File

@ -83,10 +83,9 @@ class CurrencyForm(FlaskForm):
obj.created_by_id = current_user_pk obj.created_by_id = current_user_pk
obj.updated_by_id = current_user_pk obj.updated_by_id = current_user_pk
def post_update(self, obj: Currency) -> None: def post_update(self, obj) -> None:
"""The post-processing after the update. """The post-processing after the update.
:param obj: The currency object.
:return: None :return: None
""" """
current_user_pk: int = get_current_user_pk() 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 import db
from accounting.locale import lazy_gettext from accounting.locale import lazy_gettext
from accounting.models import Currency from accounting.models import Currency
from accounting.utils.next_uri import inherit_next, or_next from accounting.utils.next_url import inherit_next, or_next
from accounting.utils.pagination import Pagination from accounting.utils.pagination import Pagination
from accounting.utils.permission import has_permission, can_view, can_edit from accounting.utils.permission import has_permission, can_view, can_edit
from .forms import CurrencyForm from .forms import CurrencyForm

View File

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

View File

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

View File

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

View File

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