Renamed the URL transactions.show to transactions.detail, teh templates show.html to detail.html, and the view txn_show() to txn_detail, to follow the naming convention of Django in the accounting application.

This commit is contained in:
依瑪貓 2020-08-08 15:43:21 +08:00
parent ece7dbe62f
commit 908fbedf0d
14 changed files with 25 additions and 25 deletions

View File

@ -156,13 +156,13 @@ class Transaction(DirtyFieldsMixin, models.Model):
"""Returns the URL to view this transaction.""" """Returns the URL to view this transaction."""
if self.is_cash_expense: if self.is_cash_expense:
return reverse( return reverse(
"accounting:transactions.show", args=("expense", self)) "accounting:transactions.detail", args=("expense", self))
elif self.is_cash_income: elif self.is_cash_income:
return reverse( return reverse(
"accounting:transactions.show", args=("income", self)) "accounting:transactions.detail", args=("income", self))
else: else:
return reverse( return reverse(
"accounting:transactions.show", args=("transfer", self)) "accounting:transactions.detail", args=("transfer", self))
def is_dirty(self, **kwargs): def is_dirty(self, **kwargs):
"""Returns whether the data of this transaction is changed and need """Returns whether the data of this transaction is changed and need

View File

@ -122,7 +122,7 @@ First written: 2020/7/1
<td class="amount {% if record.balance < 0 %} text-danger {% endif %}">{{ record.balance|accounting_amount }}</td> <td class="amount {% if record.balance < 0 %} text-danger {% endif %}">{{ record.balance|accounting_amount }}</td>
<td class="actions"> <td class="actions">
{% if record.pk is not None %} {% if record.pk is not None %}
<a href="{% url_with_return "accounting:transactions.show" record.transaction.type record.transaction %}" class="btn btn-info" role="button"> <a href="{% url_with_return "accounting:transactions.detail" record.transaction.type record.transaction %}" class="btn btn-info" role="button">
<i class="fas fa-eye"></i> <i class="fas fa-eye"></i>
<span class="d-none d-lg-inline">{{ _("View")|force_escape }}</span> <span class="d-none d-lg-inline">{{ _("View")|force_escape }}</span>
</a> </a>
@ -138,7 +138,7 @@ First written: 2020/7/1
{% for record in record_list %} {% for record in record_list %}
<li class="list-group-item {% if not record.is_balanced or record.has_order_hole %} list-group-item-danger {% endif %}"> <li class="list-group-item {% if not record.is_balanced or record.has_order_hole %} list-group-item-danger {% endif %}">
{% if record.pk is not None %} {% if record.pk is not None %}
<a class="list-group-item-action" href="{% url_with_return "accounting:transactions.show" record.transaction.type record.transaction %}"> <a class="list-group-item-action" href="{% url_with_return "accounting:transactions.detail" record.transaction.type record.transaction %}">
<div class="date-account-line d-flex justify-content-between align-items-center"> <div class="date-account-line d-flex justify-content-between align-items-center">
{{ record.transaction.date|smart_date }} {{ record.account.title|title_case }} {{ record.transaction.date|smart_date }} {{ record.account.title|title_case }}
</div> </div>

View File

@ -102,7 +102,7 @@ First written: 2020/7/17
<td>{{ record.transaction.note|default:"" }}</td> <td>{{ record.transaction.note|default:"" }}</td>
<td class="actions"> <td class="actions">
{% if record.pk is not None %} {% if record.pk is not None %}
<a href="{% url_with_return "accounting:transactions.show" record.transaction.type record.transaction %}" class="btn btn-info" role="button"> <a href="{% url_with_return "accounting:transactions.detail" record.transaction.type record.transaction %}" class="btn btn-info" role="button">
<i class="fas fa-eye"></i> <i class="fas fa-eye"></i>
{{ _("View")|force_escape }} {{ _("View")|force_escape }}
</a> </a>
@ -118,7 +118,7 @@ First written: 2020/7/17
{% for record in record_list %} {% for record in record_list %}
<li class="list-group-item {% if not record.is_balanced or record.has_order_hole %} list-group-item-danger {% endif %}"> <li class="list-group-item {% if not record.is_balanced or record.has_order_hole %} list-group-item-danger {% endif %}">
{% if record.pk is not None %} {% if record.pk is not None %}
<a class="list-group-item-action" href="{% url_with_return "accounting:transactions.show" record.transaction.type record.transaction %}"> <a class="list-group-item-action" href="{% url_with_return "accounting:transactions.detail" record.transaction.type record.transaction %}">
<div class="{% if record.is_credit %} journal-credit {% else %} journal-debit {% endif %}"> <div class="{% if record.is_credit %} journal-credit {% else %} journal-debit {% endif %}">
<div class="date-account-line"> <div class="date-account-line">
{{ record.transaction.date|smart_date }} {{ record.account.title|title_case }} {{ record.transaction.date|smart_date }} {{ record.account.title|title_case }}

View File

@ -123,7 +123,7 @@ First written: 2020/7/16
<td class="amount {% if record.balance < 0 %} text-danger {% endif %}">{{ record.balance|accounting_amount }}</td> <td class="amount {% if record.balance < 0 %} text-danger {% endif %}">{{ record.balance|accounting_amount }}</td>
<td class="actions"> <td class="actions">
{% if record.pk is not None %} {% if record.pk is not None %}
<a href="{% url_with_return "accounting:transactions.show" record.transaction.type record.transaction %}" class="btn btn-info" role="button"> <a href="{% url_with_return "accounting:transactions.detail" record.transaction.type record.transaction %}" class="btn btn-info" role="button">
<i class="fas fa-eye"></i> <i class="fas fa-eye"></i>
<span class="d-none d-lg-inline">{{ _("View")|force_escape }}</span> <span class="d-none d-lg-inline">{{ _("View")|force_escape }}</span>
</a> </a>
@ -139,7 +139,7 @@ First written: 2020/7/16
{% for record in record_list %} {% for record in record_list %}
<li class="list-group-item {% if not record.is_balanced or record.has_order_hole or record.is_payable %} list-group-item-danger {% endif %}{% if record.is_existing_equipment %} list-group-item-info {% endif %}"> <li class="list-group-item {% if not record.is_balanced or record.has_order_hole or record.is_payable %} list-group-item-danger {% endif %}{% if record.is_existing_equipment %} list-group-item-info {% endif %}">
{% if record.pk is not None %} {% if record.pk is not None %}
<a class="list-group-item-action" href="{% url_with_return "accounting:transactions.show" record.transaction.type record.transaction %}"> <a class="list-group-item-action" href="{% url_with_return "accounting:transactions.detail" record.transaction.type record.transaction %}">
<div class="date-account-line"> <div class="date-account-line">
{{ record.transaction.date|smart_date }} {{ record.account.title|title_case }} {{ record.transaction.date|smart_date }} {{ record.account.title|title_case }}
</div> </div>

View File

@ -100,7 +100,7 @@ First written: 2020/7/21
<td class="amount">{{ record.credit_amount|accounting_amount }}</td> <td class="amount">{{ record.credit_amount|accounting_amount }}</td>
<td>{{ record.transaction.notes|default:"" }}</td> <td>{{ record.transaction.notes|default:"" }}</td>
<td class="actions"> <td class="actions">
<a href="{% url_with_return "accounting:transactions.show" record.transaction.type record.transaction %}" class="btn btn-info" role="button"> <a href="{% url_with_return "accounting:transactions.detail" record.transaction.type record.transaction %}" class="btn btn-info" role="button">
<i class="fas fa-eye"></i> <i class="fas fa-eye"></i>
{{ _("View")|force_escape }} {{ _("View")|force_escape }}
</a> </a>
@ -114,7 +114,7 @@ First written: 2020/7/21
<ul class="list-group d-md-none"> <ul class="list-group d-md-none">
{% for record in record_list %} {% for record in record_list %}
<li class="list-group-item {% if not record.is_balanced or record.has_order_hole %} list-group-item-danger {% endif %}"> <li class="list-group-item {% if not record.is_balanced or record.has_order_hole %} list-group-item-danger {% endif %}">
<a class="list-group-item-action" href="{% url_with_return "accounting:transactions.show" record.transaction.type record.transaction %}"> <a class="list-group-item-action" href="{% url_with_return "accounting:transactions.detail" record.transaction.type record.transaction %}">
<div class="{% if record.is_credit %} journal-credit {% else %} journal-debit {% endif %}"> <div class="{% if record.is_credit %} journal-credit {% else %} journal-debit {% endif %}">
<div class="date-account-line"> <div class="date-account-line">
{{ record.transaction.date|smart_date }} {{ record.account.title|title_case }} {{ record.transaction.date|smart_date }} {{ record.account.title|title_case }}

View File

@ -86,7 +86,7 @@ First written: 2020/7/23
{{ _("Sort")|force_escape }} {{ _("Sort")|force_escape }}
</a> </a>
{% endif %} {% endif %}
<a class="btn btn-primary d-none d-sm-inline" href="{% url_keep_return "accounting:transactions.show" "transfer" txn %}"> <a class="btn btn-primary d-none d-sm-inline" href="{% url_keep_return "accounting:transactions.detail" "transfer" txn %}">
<i class="fas fa-exchange-alt"></i> <i class="fas fa-exchange-alt"></i>
{{ _("To Transfer")|force_escape }} {{ _("To Transfer")|force_escape }}
</a> </a>
@ -106,7 +106,7 @@ First written: 2020/7/23
{{ _("Sort")|force_escape }} {{ _("Sort")|force_escape }}
</a> </a>
{% endif %} {% endif %}
<a class="dropdown-item" href="{% url_keep_return "accounting:transactions.show" "transfer" txn %}"> <a class="dropdown-item" href="{% url_keep_return "accounting:transactions.detail" "transfer" txn %}">
<i class="fas fa-exchange-alt"></i> <i class="fas fa-exchange-alt"></i>
{{ _("To Transfer")|force_escape }} {{ _("To Transfer")|force_escape }}
</a> </a>

View File

@ -46,7 +46,7 @@ First written: 2020/7/23
{% endfor %} {% endfor %}
<div class="btn-group btn-actions"> <div class="btn-group btn-actions">
<a class="btn btn-primary" role="button" href="{% if txn.transaction %}{% url_keep_return "accounting:transactions.show" "expense" txn.transaction %}{% elif request.GET.r %}{{ request.GET.r }}{% else %}{% url "accounting:home" %}{% endif %}"> <a class="btn btn-primary" role="button" href="{% if txn.transaction %}{% url_keep_return "accounting:transactions.detail" "expense" txn.transaction %}{% elif request.GET.r %}{{ request.GET.r }}{% else %}{% url "accounting:home" %}{% endif %}">
<i class="fas fa-chevron-circle-left"></i> <i class="fas fa-chevron-circle-left"></i>
{{ _("Back")|force_escape }} {{ _("Back")|force_escape }}
</a> </a>

View File

@ -86,7 +86,7 @@ First written: 2020/7/23
{{ _("Sort")|force_escape }} {{ _("Sort")|force_escape }}
</a> </a>
{% endif %} {% endif %}
<a class="btn btn-primary d-none d-sm-inline" href="{% url_keep_return "accounting:transactions.show" "transfer" txn %}"> <a class="btn btn-primary d-none d-sm-inline" href="{% url_keep_return "accounting:transactions.detail" "transfer" txn %}">
<i class="fas fa-exchange-alt"></i> <i class="fas fa-exchange-alt"></i>
{{ _("To Transfer")|force_escape }} {{ _("To Transfer")|force_escape }}
</a> </a>
@ -106,7 +106,7 @@ First written: 2020/7/23
{{ _("Sort")|force_escape }} {{ _("Sort")|force_escape }}
</a> </a>
{% endif %} {% endif %}
<a class="dropdown-item" href="{% url_keep_return "accounting:transactions.show" "transfer" txn %}"> <a class="dropdown-item" href="{% url_keep_return "accounting:transactions.detail" "transfer" txn %}">
<i class="fas fa-exchange-alt"></i> <i class="fas fa-exchange-alt"></i>
{{ _("To Transfer")|force_escape }} {{ _("To Transfer")|force_escape }}
</a> </a>

View File

@ -46,7 +46,7 @@ First written: 2020/7/23
{% endfor %} {% endfor %}
<div class="btn-group btn-actions"> <div class="btn-group btn-actions">
<a class="btn btn-primary" role="button" href="{% if txn.transaction %}{% url_keep_return "accounting:transactions.show" "income" txn.transaction %}{% elif request.GET.r %}{{ request.GET.r }}{% else %}{% url "accounting:home" %}{% endif %}"> <a class="btn btn-primary" role="button" href="{% if txn.transaction %}{% url_keep_return "accounting:transactions.detail" "income" txn.transaction %}{% elif request.GET.r %}{{ request.GET.r }}{% else %}{% url "accounting:home" %}{% endif %}">
<i class="fas fa-chevron-circle-left"></i> <i class="fas fa-chevron-circle-left"></i>
{{ _("Back")|force_escape }} {{ _("Back")|force_escape }}
</a> </a>

View File

@ -75,7 +75,7 @@ First written: 2020/8/6
<button class="btn btn-outline-secondary" type="button"> <button class="btn btn-outline-secondary" type="button">
<i class="fas fa-sort"></i> <i class="fas fa-sort"></i>
</button> </button>
<a class="btn btn-primary" role="button" href="{% url_with_return "accounting:transactions.show" txn.type txn %}"> <a class="btn btn-primary" role="button" href="{% url_with_return "accounting:transactions.detail" txn.type txn %}">
<i class="fas fa-eye"></i> <i class="fas fa-eye"></i>
</a> </a>
</div> </div>

View File

@ -46,7 +46,7 @@ First written: 2020/7/23
{% endfor %} {% endfor %}
<div class="btn-group btn-actions"> <div class="btn-group btn-actions">
<a class="btn btn-primary" role="button" href="{% if txn.transaction %}{% url_keep_return "accounting:transactions.show" "transfer" txn.transaction %}{% elif request.GET.r %}{{ request.GET.r }}{% else %}{% url "accounting:home" %}{% endif %}"> <a class="btn btn-primary" role="button" href="{% if txn.transaction %}{% url_keep_return "accounting:transactions.detail" "transfer" txn.transaction %}{% elif request.GET.r %}{{ request.GET.r }}{% else %}{% url "accounting:home" %}{% endif %}">
<i class="fas fa-chevron-circle-left"></i> <i class="fas fa-chevron-circle-left"></i>
{{ _("Back")|force_escape }} {{ _("Back")|force_escape }}
</a> </a>

View File

@ -81,7 +81,7 @@ urlpatterns = [
path("transactions/<txn-type:txn_type>/store", path("transactions/<txn-type:txn_type>/store",
views.txn_store, name="transactions.store"), views.txn_store, name="transactions.store"),
path("transactions/<txn-type:txn_type>/<txn:txn>", path("transactions/<txn-type:txn_type>/<txn:txn>",
views.txn_show, name="transactions.show"), views.txn_detail, name="transactions.detail"),
path("transactions/<txn-type:txn_type>/<txn:txn>/edit", path("transactions/<txn-type:txn_type>/<txn:txn>/edit",
views.txn_edit, name="transactions.edit"), views.txn_edit, name="transactions.edit"),
path("transactions/<txn-type:txn_type>/<txn:txn>/update", path("transactions/<txn-type:txn_type>/<txn:txn>/update",

View File

@ -801,8 +801,8 @@ def search(request):
@require_GET @require_GET
@login_required @login_required
def txn_show(request, txn_type, txn): def txn_detail(request, txn_type, txn):
"""The view of an accounting transaction. """The view of the details of an accounting transaction.
Args: Args:
request (HttpRequest): The request. request (HttpRequest): The request.
@ -812,7 +812,7 @@ def txn_show(request, txn_type, txn):
Returns: Returns:
HttpResponse: The response. HttpResponse: The response.
""" """
return render(request, F"accounting/transactions/{txn_type}/view.html", { return render(request, F"accounting/transactions/{txn_type}/detail.html", {
"txn": txn, "txn": txn,
}) })
@ -893,7 +893,7 @@ def txn_store(request, txn_type, txn=None):
if not txn.is_dirty(): if not txn.is_dirty():
messages.success(request, gettext_noop( messages.success(request, gettext_noop(
"This transaction was not modified.")) "This transaction was not modified."))
url = reverse("accounting:transactions.show", args=(txn_type, txn)) url = reverse("accounting:transactions.detail", 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 HttpResponseRedirect(url) return HttpResponseRedirect(url)
@ -940,7 +940,7 @@ def txn_store(request, txn_type, txn=None):
x.save() x.save()
messages.success(request, gettext_noop( messages.success(request, gettext_noop(
"This transaction was saved successfully.")) "This transaction was saved successfully."))
url = reverse("accounting:transactions.show", args=(txn_type, txn)) url = reverse("accounting:transactions.detail", 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 HttpResponseRedirect(url) return HttpResponseRedirect(url)