Renamed the parameter type to txn_type in the transaction views in the accounting application.

This commit is contained in:
依瑪貓 2020-07-29 15:06:23 +08:00
parent 63d83e0e4d
commit d6428a002e
2 changed files with 16 additions and 16 deletions

View File

@ -67,15 +67,15 @@ urlpatterns = [
views.balance_sheet, name="balance-sheet"), views.balance_sheet, name="balance-sheet"),
path("search", path("search",
views.search, name="search"), views.search, name="search"),
path("transactions/<txn-type:type>/create", path("transactions/<txn-type:txn_type>/create",
views.transaction_edit, name="transactions.create"), views.transaction_edit, name="transactions.create"),
path("transactions/<txn-type:type>/store", path("transactions/<txn-type:txn_type>/store",
views.transaction_store, name="transactions.store"), views.transaction_store, name="transactions.store"),
path("transactions/<txn-type:type>/<txn:transaction>", path("transactions/<txn-type:txn_type>/<txn:transaction>",
views.transaction_show, name="transactions.show"), views.transaction_show, name="transactions.show"),
path("transactions/<txn-type:type>/<txn:transaction>/edit", path("transactions/<txn-type:txn_type>/<txn:transaction>/edit",
views.transaction_edit, name="transactions.edit"), views.transaction_edit, name="transactions.edit"),
path("transactions/<txn-type:type>/<txn:transaction>/update", path("transactions/<txn-type:txn_type>/<txn:transaction>/update",
views.transaction_store, name="transactions.update"), views.transaction_store, name="transactions.update"),
path("transactions/<txn:transaction>/delete", path("transactions/<txn:transaction>/delete",
mia_core_views.todo, name="transactions.delete"), mia_core_views.todo, name="transactions.delete"),

View File

@ -847,30 +847,30 @@ def search(request):
@require_GET @require_GET
@digest_login_required @digest_login_required
def transaction_show(request, type, transaction): def transaction_show(request, txn_type, transaction):
"""The view of an accounting transaction. """The view of an accounting transaction.
Args: Args:
request (HttpRequest): The request. request (HttpRequest): The request.
type (str): The transaction type. txn_type (str): The transaction type.
transaction (Transaction): The transaction. transaction (Transaction): The transaction.
Returns: Returns:
HttpResponse: The response. HttpResponse: The response.
""" """
return render(request, F"accounting/transactions/{type}/view.html", { return render(request, F"accounting/transactions/{txn_type}/view.html", {
"item": transaction, "item": transaction,
}) })
@require_GET @require_GET
@digest_login_required @digest_login_required
def transaction_edit(request, type, transaction=None): def transaction_edit(request, txn_type, transaction=None):
"""The view to edit an accounting transaction. """The view to edit an accounting transaction.
Args: Args:
request (HttpRequest): The request. request (HttpRequest): The request.
type (str): The transaction type. txn_type (str): The transaction type.
transaction (Transaction): The transaction. transaction (Transaction): The transaction.
Returns: Returns:
@ -883,19 +883,19 @@ def transaction_edit(request, type, transaction=None):
transaction.records.append(Record(ord=1, is_credit=False)) transaction.records.append(Record(ord=1, is_credit=False))
if len(transaction.credit_records) == 0: if len(transaction.credit_records) == 0:
transaction.records.append(Record(ord=1, is_credit=True)) transaction.records.append(Record(ord=1, is_credit=True))
return render(request, F"accounting/transactions/{type}/form.html", { return render(request, F"accounting/transactions/{txn_type}/form.html", {
"item": transaction, "item": transaction,
}) })
@require_POST @require_POST
@digest_login_required @digest_login_required
def transaction_store(request, type, transaction=None): def transaction_store(request, txn_type, transaction=None):
"""The view to store an accounting transaction. """The view to store an accounting transaction.
Args: Args:
request (HttpRequest): The request. request (HttpRequest): The request.
type (str): The transaction type. txn_type (str): The transaction type.
transaction (Transaction): The transaction. transaction (Transaction): The transaction.
Returns: Returns:
@ -968,10 +968,10 @@ def transaction_store(request, type, transaction=None):
"This record is not of the same transaction.") "This record is not of the same transaction.")
if len(errors) > 0: if len(errors) > 0:
if transaction.pk is None: if transaction.pk is None:
url = reverse("accounting:transactions.create", args=(type,)) url = reverse("accounting:transactions.create", args=(txn_type,))
else: else:
url = reverse( url = reverse(
"accounting:transactions.edit", args=(type, transaction)) "accounting:transactions.edit", args=(txn_type, transaction))
return error_redirect( return error_redirect(
request, request,
str(UrlBuilder(url).add_param("r", request.GET.get("r"))), str(UrlBuilder(url).add_param("r", request.GET.get("r"))),
@ -980,6 +980,6 @@ def transaction_store(request, type, transaction=None):
return success_redirect( return success_redirect(
request, request,
str(UrlBuilder(reverse("accounting:transactions.show", str(UrlBuilder(reverse("accounting:transactions.show",
args=(type, transaction))) args=(txn_type, transaction)))
.add_param("r", request.GET.get("r"))), .add_param("r", request.GET.get("r"))),
gettext_noop("This transaction was saved successfully.")) gettext_noop("This transaction was saved successfully."))