From 6453cd4b8e935f86ee42e35a92658c3de9285058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Thu, 23 Jul 2020 22:32:34 +0800 Subject: [PATCH] Added the edit button to the transaction views in the accounting application. --- .../accounting/transactions/expense/show.html | 6 +++++- .../accounting/transactions/income/show.html | 6 +++++- .../accounting/transactions/transfer/show.html | 6 +++++- mia_core/templatetags/mia_core.py | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/accounting/templates/accounting/transactions/expense/show.html b/accounting/templates/accounting/transactions/expense/show.html index bfca114..bc9c3b9 100644 --- a/accounting/templates/accounting/transactions/expense/show.html +++ b/accounting/templates/accounting/transactions/expense/show.html @@ -42,7 +42,11 @@ First written: 2020/7/23
- {{ _("Back") }} + {% trans "Back" context "Navigation|" as text %}{{ text|force_escape }} + + + + {% trans "Edit" context "Navigation|" as text %}{{ text|force_escape }}
diff --git a/accounting/templates/accounting/transactions/income/show.html b/accounting/templates/accounting/transactions/income/show.html index 875c7a0..1e19b68 100644 --- a/accounting/templates/accounting/transactions/income/show.html +++ b/accounting/templates/accounting/transactions/income/show.html @@ -42,7 +42,11 @@ First written: 2020/7/23
- {{ _("Back") }} + {% trans "Back" context "Navigation|" as text %}{{ text|force_escape }} + + + + {% trans "Edit" context "Navigation|" as text %}{{ text|force_escape }}
diff --git a/accounting/templates/accounting/transactions/transfer/show.html b/accounting/templates/accounting/transactions/transfer/show.html index ab36000..ecb4309 100644 --- a/accounting/templates/accounting/transactions/transfer/show.html +++ b/accounting/templates/accounting/transactions/transfer/show.html @@ -42,7 +42,11 @@ First written: 2020/7/23
- {{ _("Back") }} + {% trans "Back" context "Navigation|" as text %}{{ text|force_escape }} + + + + {% trans "Edit" context "Navigation|" as text %}{{ text|force_escape }}
diff --git a/mia_core/templatetags/mia_core.py b/mia_core/templatetags/mia_core.py index 0fd445a..ad456c7 100644 --- a/mia_core/templatetags/mia_core.py +++ b/mia_core/templatetags/mia_core.py @@ -137,3 +137,19 @@ def url_with_return(context, view_name, *args): url = reverse(view_name, args=args) return_to = context.request.get_full_path() return str(UrlBuilder(url).set_param("r", return_to)) + + +@register.simple_tag(takes_context=True) +def url_keep_return(context, view_name, *args): + """Returns the transaction URL. + + Args: + context (RequestContext): The request context. + view_name (str): The view name. + *args (tuple[any]): The URL arguments. + + Returns: + str: The URL. + """ + url = reverse(view_name, args=args) + return str(UrlBuilder(url).set_param("r", context.request.GET.get("r")))