Added the action buttons to the transaction views in the accounting application.
This commit is contained in:
parent
43d51a5519
commit
ff8c92a711
@ -18,6 +18,8 @@
|
||||
"""The URL converters.
|
||||
|
||||
"""
|
||||
import datetime
|
||||
import re
|
||||
|
||||
from django.utils.translation import pgettext
|
||||
|
||||
@ -74,6 +76,37 @@ class PeriodConverter:
|
||||
return value
|
||||
|
||||
|
||||
class DateConverter:
|
||||
"""The path converter for the date."""
|
||||
regex = "([0-9]{4})-([0-9]{2})-([0-9]{2})"
|
||||
|
||||
def to_python(self, value):
|
||||
"""Returns the date by the date specification.
|
||||
|
||||
Args:
|
||||
value (str): The date specification.
|
||||
|
||||
Returns:
|
||||
datetime.date: The date.
|
||||
"""
|
||||
m = re.match("^([0-9]{4})-([0-9]{2})-([0-9]{2})$", value)
|
||||
year = int(m.group(1))
|
||||
month = int(m.group(2))
|
||||
day = int(m.group(3))
|
||||
return datetime.date(year, month, day)
|
||||
|
||||
def to_url(self, value):
|
||||
"""Returns the specification of a date.
|
||||
|
||||
Args:
|
||||
value (datetime.date): The date.
|
||||
|
||||
Returns:
|
||||
str: The date specification.
|
||||
"""
|
||||
return value.strftime("%Y-%m-%d")
|
||||
|
||||
|
||||
class CashAccountConverter:
|
||||
"""The path converter for the cash account."""
|
||||
regex = "0|(11|12|21|22)[1-9]{1,3}"
|
||||
|
@ -39,6 +39,33 @@ First written: 2020/7/23
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- the delete confirmation dialog -->
|
||||
<form action="{% url_keep_return "accounting:transactions.delete" item %}" method="post">
|
||||
{% csrf_token %}
|
||||
<!-- The Modal -->
|
||||
<div class="modal" id="del-modal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<!-- Modal Header -->
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{% trans "Cash Expense Transaction Deletion Confirmation" context "Accounting|" as text %}{{ text|force_escape }}</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
|
||||
<!-- Modal body -->
|
||||
<div class="modal-body">{% trans "Do you really want to delete this cash expense transaction?" context "Accounting|" as text %}{{ text|force_escape }}</div>
|
||||
|
||||
<!-- Modal footer -->
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-danger" type="submit" name="del-confirm">{{ _("Confirm") }}</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ _("Cancel") }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="btn-group btn-actions">
|
||||
<a class="btn btn-primary" role="button" href="{{ request.GET.r }}">
|
||||
<i class="fas fa-chevron-circle-left"></i>
|
||||
@ -48,6 +75,47 @@ First written: 2020/7/23
|
||||
<i class="fas fa-edit"></i>
|
||||
{% trans "Edit" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
{% if not item.has_many_same_day %}
|
||||
<button type="button" class="btn btn-secondary d-none d-sm-inline" disabled="disabled" title="{% trans "There is no other transaction at the same day." context "Accounting|" as text %}{{ text|force_escape }}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</button>
|
||||
{% else %}
|
||||
<a class="btn btn-primary d-none d-sm-inline" role="button" href="{% url_with_return "accounting:transactions.sort" item.date %}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
{% endif %}
|
||||
<a class="btn btn-primary d-none d-sm-inline" href="{% url_keep_return "accounting:transactions.show" "transfer" item %}">
|
||||
<i class="fas fa-exchange-alt"></i>
|
||||
{% trans "To Transfer" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
<div class="btn-group d-sm-none">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
|
||||
<i class="fas fa-bars"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
{% if not item.has_many_same_day %}
|
||||
<span class="dropdown-item disabled" title="{% trans "There is no other transaction at the same day." context "Accounting|" as text %}{{ text|force_escape }}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</span>
|
||||
{% else %}
|
||||
<a class="dropdown-item" href="{% url_with_return "accounting:transactions.sort" item.date %}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
{% endif %}
|
||||
<a class="dropdown-item" href="{% url_keep_return "accounting:transactions.show" "transfer" item %}">
|
||||
<i class="fas fa-exchange-alt"></i>
|
||||
{% trans "To Transfer" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#del-modal">
|
||||
<i class="fas fa-trash"></i>
|
||||
{% trans "Delete" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
@ -39,6 +39,33 @@ First written: 2020/7/23
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- the delete confirmation dialog -->
|
||||
<form action="{% url_keep_return "accounting:transactions.delete" item %}" method="post">
|
||||
{% csrf_token %}
|
||||
<!-- The Modal -->
|
||||
<div class="modal" id="del-modal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<!-- Modal Header -->
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{% trans "Cash Income Transaction Deletion Confirmation" context "Accounting|" as text %}{{ text|force_escape }}</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
|
||||
<!-- Modal body -->
|
||||
<div class="modal-body">{% trans "Do you really want to delete this cash income transaction?" context "Accounting|" as text %}{{ text|force_escape }}</div>
|
||||
|
||||
<!-- Modal footer -->
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-danger" type="submit" name="del-confirm">{{ _("Confirm") }}</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ _("Cancel") }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="btn-group btn-actions">
|
||||
<a class="btn btn-primary" role="button" href="{{ request.GET.r }}">
|
||||
<i class="fas fa-chevron-circle-left"></i>
|
||||
@ -48,6 +75,47 @@ First written: 2020/7/23
|
||||
<i class="fas fa-edit"></i>
|
||||
{% trans "Edit" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
{% if not item.has_many_same_day %}
|
||||
<button type="button" class="btn btn-secondary d-none d-sm-inline" disabled="disabled" title="{% trans "There is no other transaction at the same day." context "Accounting|" as text %}{{ text|force_escape }}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</button>
|
||||
{% else %}
|
||||
<a class="btn btn-primary d-none d-sm-inline" role="button" href="{% url_with_return "accounting:transactions.sort" item.date %}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
{% endif %}
|
||||
<a class="btn btn-primary d-none d-sm-inline" href="{% url_keep_return "accounting:transactions.show" "transfer" item %}">
|
||||
<i class="fas fa-exchange-alt"></i>
|
||||
{% trans "To Transfer" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
<div class="btn-group d-sm-none">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
|
||||
<i class="fas fa-bars"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
{% if not item.has_many_same_day %}
|
||||
<span class="dropdown-item disabled" title="{% trans "There is no other transaction at the same day." context "Accounting|" as text %}{{ text|force_escape }}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</span>
|
||||
{% else %}
|
||||
<a class="dropdown-item" href="{% url_with_return "accounting:transactions.sort" item.date %}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
{% endif %}
|
||||
<a class="dropdown-item" href="{% url_keep_return "accounting:transactions.show" "transfer" item %}">
|
||||
<i class="fas fa-exchange-alt"></i>
|
||||
{% trans "To Transfer" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#del-modal">
|
||||
<i class="fas fa-trash"></i>
|
||||
{% trans "Delete" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
@ -39,6 +39,33 @@ First written: 2020/7/23
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- the delete confirmation dialog -->
|
||||
<form action="{% url_keep_return "accounting:transactions.delete" item %}" method="post">
|
||||
{% csrf_token %}
|
||||
<!-- The Modal -->
|
||||
<div class="modal" id="del-modal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<!-- Modal Header -->
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{% trans "Transfer Transaction Deletion Confirmation" context "Accounting|" as text %}{{ text|force_escape }}</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
|
||||
<!-- Modal body -->
|
||||
<div class="modal-body">{% trans "Do you really want to delete this transfer transaction?" context "Accounting|" as text %}{{ text|force_escape }}</div>
|
||||
|
||||
<!-- Modal footer -->
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-danger" type="submit" name="del-confirm">{{ _("Confirm") }}</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ _("Cancel") }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="btn-group btn-actions">
|
||||
<a class="btn btn-primary" role="button" href="{{ request.GET.r }}">
|
||||
<i class="fas fa-chevron-circle-left"></i>
|
||||
@ -48,6 +75,39 @@ First written: 2020/7/23
|
||||
<i class="fas fa-edit"></i>
|
||||
{% trans "Edit" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
{% if not item.has_many_same_day %}
|
||||
<button type="button" class="btn btn-secondary d-none d-sm-inline" disabled="disabled" title="{% trans "There is no other transaction at the same day." context "Accounting|" as text %}{{ text|force_escape }}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</button>
|
||||
{% else %}
|
||||
<a class="btn btn-primary d-none d-sm-inline" role="button" href="{% url_with_return "accounting:transactions.sort" item.date %}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
{% endif %}
|
||||
<div class="btn-group d-sm-none">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
|
||||
<i class="fas fa-bars"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
{% if not item.has_many_same_day %}
|
||||
<span class="dropdown-item disabled" title="{% trans "There is no other transaction at the same day." context "Accounting|" as text %}{{ text|force_escape }}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</span>
|
||||
{% else %}
|
||||
<a class="dropdown-item" href="{% url_with_return "accounting:transactions.sort" item.date %}">
|
||||
<i class="fas fa-sort"></i>
|
||||
{% trans "Sort" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#del-modal">
|
||||
<i class="fas fa-trash"></i>
|
||||
{% trans "Delete" context "Navigation|" as text %}{{ text|force_escape }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
@ -29,6 +29,7 @@ register_converter(converters.CashAccountConverter, "cash-account")
|
||||
register_converter(converters.LedgerAccountConverter, "ledger-account")
|
||||
register_converter(converters.TransactionTypeConverter, "txn-type")
|
||||
register_converter(converters.TransactionConverter, "txn")
|
||||
register_converter(converters.DateConverter, "date")
|
||||
|
||||
app_name = "accounting"
|
||||
urlpatterns = [
|
||||
@ -78,6 +79,8 @@ urlpatterns = [
|
||||
mia_core_views.todo, name="transactions.update"),
|
||||
path("transactions/<txn:transaction>/delete",
|
||||
mia_core_views.todo, name="transactions.delete"),
|
||||
path("transactions/sort/<date:date>",
|
||||
mia_core_views.todo, name="transactions.sort"),
|
||||
path("accounts",
|
||||
mia_core_views.todo, name="accounts"),
|
||||
path("accounts/create",
|
||||
|
Loading…
Reference in New Issue
Block a user