Added the account deletion in the accounting application.

This commit is contained in:
依瑪貓 2020-08-09 17:25:51 +08:00
parent 50eb3f080c
commit fdbc27ba57
3 changed files with 33 additions and 6 deletions

View File

@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: mia-js 1.0\n" "Project-Id-Version: mia-js 1.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-09 17:02+0800\n" "POT-Creation-Date: 2020-08-09 17:24+0800\n"
"PO-Revision-Date: 2020-08-09 17:02+0800\n" "PO-Revision-Date: 2020-08-09 17:24+0800\n"
"Last-Translator: imacat <imacat@mail.imacat.idv.tw>\n" "Last-Translator: imacat <imacat@mail.imacat.idv.tw>\n"
"Language-Team: Traditional Chinese <imacat@mail.imacat.idv.tw>\n" "Language-Team: Traditional Chinese <imacat@mail.imacat.idv.tw>\n"
"Language: Traditional Chinese\n" "Language: Traditional Chinese\n"
@ -199,6 +199,7 @@ msgid "Ledger"
msgstr "分類帳" msgstr "分類帳"
#: accounting/templates/accounting/account_detail.html:107 #: accounting/templates/accounting/account_detail.html:107
#: accounting/views.py:1111
msgid "This account is in use." msgid "This account is in use."
msgstr "會計科目使用中。" msgstr "會計科目使用中。"
@ -901,10 +902,14 @@ msgstr "會計科目未異動。"
msgid "This account was saved successfully." msgid "This account was saved successfully."
msgstr "會計科目已存檔。" msgstr "會計科目已存檔。"
#: accounting/views.py:1135 #: accounting/views.py:1115
msgid "This account was deleted successfully."
msgstr "會計科目已刪除。"
#: accounting/views.py:1157
msgid "---Accounts In Use---" msgid "---Accounts In Use---"
msgstr "-----使用中科目-----" msgstr "-----使用中科目-----"
#: accounting/views.py:1140 #: accounting/views.py:1162
msgid "---Accounts Not In Use---" msgid "---Accounts Not In Use---"
msgstr "-----未使用科目-----" msgstr "-----未使用科目-----"

View File

@ -106,7 +106,6 @@ urlpatterns = [
views.account_form, name="accounts.edit"), views.account_form, name="accounts.edit"),
path("accounts/<account:account>/update", path("accounts/<account:account>/update",
views.account_store, name="accounts.update"), views.account_store, name="accounts.update"),
# TODO: To be done
path("accounts/<account:account>/delete", path("accounts/<account:account>/delete",
mia_core_views.todo, name="accounts.delete"), views.account_delete, name="accounts.delete"),
] ]

View File

@ -1095,6 +1095,29 @@ def account_store(request, account=None):
args=(account,))) args=(account,)))
@require_POST
@login_required
def account_delete(request, account):
"""The view to delete an accounting.
Args:
request (HttpRequest): The request.
account (Account): The account.
Returns:
HttpResponseRedirect: The response.
"""
if account.is_in_use:
message = gettext_noop("This account is in use.")
messages.error(request, message)
return HttpResponseRedirect(reverse("accounting:accounts.detail",
args=(account,)))
account.delete()
message = gettext_noop("This account was deleted successfully.")
messages.success(request, message)
return HttpResponseRedirect(reverse("accounting:accounts"))
@require_GET @require_GET
@login_required @login_required
def api_account_list(request): def api_account_list(request):