Revised the import usage of mia_core.stored_post.

This commit is contained in:
依瑪貓 2020-08-09 13:51:56 +08:00
parent 0ee5eeaacf
commit 19ea58e7a3
2 changed files with 6 additions and 6 deletions

View File

@ -31,8 +31,8 @@ from django.urls import reverse
from django.utils import timezone from django.utils import timezone
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from mia_core import stored_post
from mia_core.period import Period from mia_core.period import Period
from mia_core.stored_post import get_previous_post
from mia_core.templatetags.mia_core import smart_month from mia_core.templatetags.mia_core import smart_month
from mia_core.utils import new_pk from mia_core.utils import new_pk
from .forms import TransactionForm, RecordForm from .forms import TransactionForm, RecordForm
@ -624,7 +624,7 @@ def make_txn_form_from_status(request, txn_type, txn):
TransactionForm: The transaction form, or None if there is no TransactionForm: The transaction form, or None if there is no
previously-stored status. previously-stored status.
""" """
form = get_previous_post(request) form = stored_post.get_previous_post(request)
if form is None: if form is None:
return None return None
return make_txn_form_from_post(form, txn_type, txn) return make_txn_form_from_post(form, txn_type, txn)

View File

@ -36,9 +36,9 @@ from django.utils.translation import gettext as _, gettext_noop
from django.views.decorators.http import require_GET, require_POST from django.views.decorators.http import require_GET, require_POST
from django.views.generic import RedirectView, ListView, DetailView, DeleteView from django.views.generic import RedirectView, ListView, DetailView, DeleteView
from mia_core import stored_post
from mia_core.digest_auth import login_required from mia_core.digest_auth import login_required
from mia_core.period import Period from mia_core.period import Period
from mia_core.stored_post import error_redirect, get_previous_post
from mia_core.utils import Pagination, get_multi_lingual_search, UrlBuilder, \ from mia_core.utils import Pagination, get_multi_lingual_search, UrlBuilder, \
strip_form, new_pk, PaginationException strip_form, new_pk, PaginationException
from .forms import AccountForm from .forms import AccountForm
@ -881,7 +881,7 @@ def txn_store(request, txn_type, txn=None):
else: else:
url = reverse("accounting:transactions.edit", args=(txn_type, txn)) url = reverse("accounting:transactions.edit", args=(txn_type, txn))
url = str(UrlBuilder(url).query(r=request.GET.get("r"))) url = str(UrlBuilder(url).query(r=request.GET.get("r")))
return error_redirect(request, url, post) return stored_post.error_redirect(request, url, post)
if txn is None: if txn is None:
txn = Transaction() txn = Transaction()
@ -996,7 +996,7 @@ def txn_sort(request, date):
errors[key] = gettext_noop("Invalid order.") errors[key] = gettext_noop("Invalid order.")
if len(errors) > 0: if len(errors) > 0:
return error_redirect( return stored_post.error_redirect(
request, reverse("accounting:transactions.sort"), post) request, reverse("accounting:transactions.sort"), post)
keys = [F"transaction-{x.pk}-ord" for x in transactions] keys = [F"transaction-{x.pk}-ord" for x in transactions]
@ -1049,7 +1049,7 @@ def account_form(request, account=None):
Returns: Returns:
HttpResponse: The response. HttpResponse: The response.
""" """
previous_post = get_previous_post(request) previous_post = stored_post.get_previous_post(request)
if previous_post is not None: if previous_post is not None:
form = AccountForm(previous_post) form = AccountForm(previous_post)
elif account is not None: elif account is not None: