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."""
if self.is_cash_expense:
return reverse(
"accounting:transactions.show", args=("expense", self))
"accounting:transactions.detail", args=("expense", self))
elif self.is_cash_income:
return reverse(
"accounting:transactions.show", args=("income", self))
"accounting:transactions.detail", args=("income", self))
else:
return reverse(
"accounting:transactions.show", args=("transfer", self))
"accounting:transactions.detail", args=("transfer", self))
def is_dirty(self, **kwargs):
"""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="actions">
{% 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>
<span class="d-none d-lg-inline">{{ _("View")|force_escape }}</span>
</a>
@ -138,7 +138,7 @@ First written: 2020/7/1
{% 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 %}">
{% 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">
{{ record.transaction.date|smart_date }} {{ record.account.title|title_case }}
</div>

View File

@ -102,7 +102,7 @@ First written: 2020/7/17
<td>{{ record.transaction.note|default:"" }}</td>
<td class="actions">
{% 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>
{{ _("View")|force_escape }}
</a>
@ -118,7 +118,7 @@ First written: 2020/7/17
{% 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 %}">
{% 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="date-account-line">
{{ 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="actions">
{% 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>
<span class="d-none d-lg-inline">{{ _("View")|force_escape }}</span>
</a>
@ -139,7 +139,7 @@ First written: 2020/7/16
{% 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 %}">
{% 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">
{{ record.transaction.date|smart_date }} {{ record.account.title|title_case }}
</div>

View File

@ -100,7 +100,7 @@ First written: 2020/7/21
<td class="amount">{{ record.credit_amount|accounting_amount }}</td>
<td>{{ record.transaction.notes|default:"" }}</td>
<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>
{{ _("View")|force_escape }}
</a>
@ -114,7 +114,7 @@ First written: 2020/7/21
<ul class="list-group d-md-none">
{% 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 %}">
<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="date-account-line">
{{ record.transaction.date|smart_date }} {{ record.account.title|title_case }}

View File

@ -86,7 +86,7 @@ First written: 2020/7/23
{{ _("Sort")|force_escape }}
</a>
{% 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>
{{ _("To Transfer")|force_escape }}
</a>
@ -106,7 +106,7 @@ First written: 2020/7/23
{{ _("Sort")|force_escape }}
</a>
{% 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>
{{ _("To Transfer")|force_escape }}
</a>

View File

@ -46,7 +46,7 @@ First written: 2020/7/23
{% endfor %}
<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>
{{ _("Back")|force_escape }}
</a>

View File

@ -86,7 +86,7 @@ First written: 2020/7/23
{{ _("Sort")|force_escape }}
</a>
{% 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>
{{ _("To Transfer")|force_escape }}
</a>
@ -106,7 +106,7 @@ First written: 2020/7/23
{{ _("Sort")|force_escape }}
</a>
{% 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>
{{ _("To Transfer")|force_escape }}
</a>

View File

@ -46,7 +46,7 @@ First written: 2020/7/23
{% endfor %}
<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>
{{ _("Back")|force_escape }}
</a>

View File

@ -75,7 +75,7 @@ First written: 2020/8/6
<button class="btn btn-outline-secondary" type="button">
<i class="fas fa-sort"></i>
</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>
</a>
</div>

View File

@ -46,7 +46,7 @@ First written: 2020/7/23
{% endfor %}
<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>
{{ _("Back")|force_escape }}
</a>

View File

@ -81,7 +81,7 @@ urlpatterns = [
path("transactions/<txn-type:txn_type>/store",
views.txn_store, name="transactions.store"),
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",
views.txn_edit, name="transactions.edit"),
path("transactions/<txn-type:txn_type>/<txn:txn>/update",

View File

@ -801,8 +801,8 @@ def search(request):
@require_GET
@login_required
def txn_show(request, txn_type, txn):
"""The view of an accounting transaction.
def txn_detail(request, txn_type, txn):
"""The view of the details of an accounting transaction.
Args:
request (HttpRequest): The request.
@ -812,7 +812,7 @@ def txn_show(request, txn_type, txn):
Returns:
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,
})
@ -893,7 +893,7 @@ def txn_store(request, txn_type, txn=None):
if not txn.is_dirty():
messages.success(request, gettext_noop(
"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")))
return HttpResponseRedirect(url)
@ -940,7 +940,7 @@ def txn_store(request, txn_type, txn=None):
x.save()
messages.success(request, gettext_noop(
"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")))
return HttpResponseRedirect(url)