Moved the dummy record creation of the new transaction forms from the view to the templates, reducing the complexity of the control logic in the view in the accounting application.
This commit is contained in:
parent
0996fa59f8
commit
94243b676a
@ -76,6 +76,10 @@ First written: 2020/7/23
|
||||
{% with record_type="debit" no=forloop.counter order=forloop.counter %}
|
||||
{% include "accounting/include/record_form-non-transfer.html" %}
|
||||
{% endwith %}
|
||||
{% empty %}
|
||||
{% with record_type="debit" no=1 order=1 %}
|
||||
{% include "accounting/include/record_form-non-transfer.html" %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<ul class="list-group">
|
||||
|
@ -75,6 +75,10 @@ First written: 2020/7/23
|
||||
{% with record_type="credit" no=forloop.counter order=forloop.counter %}
|
||||
{% include "accounting/include/record_form-non-transfer.html" %}
|
||||
{% endwith %}
|
||||
{% empty %}
|
||||
{% with record_type="credit" no=1 order=1 %}
|
||||
{% include "accounting/include/record_form-non-transfer.html" %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<ul class="list-group">
|
||||
|
@ -77,6 +77,10 @@ First written: 2020/7/23
|
||||
{% with record_type="debit" no=forloop.counter order=forloop.counter %}
|
||||
{% include "accounting/include/record_form-transfer.html" %}
|
||||
{% endwith %}
|
||||
{% empty %}
|
||||
{% with record_type="debit" no=1 order=1 %}
|
||||
{% include "accounting/include/record_form-transfer.html" %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<ul class="list-group">
|
||||
@ -103,6 +107,10 @@ First written: 2020/7/23
|
||||
{% with record_type="credit" no=forloop.counter order=forloop.counter %}
|
||||
{% include "accounting/include/record_form-transfer.html" %}
|
||||
{% endwith %}
|
||||
{% empty %}
|
||||
{% with record_type="credit" no=1 order=1 %}
|
||||
{% include "accounting/include/record_form-transfer.html" %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<ul class="list-group">
|
||||
|
@ -827,8 +827,6 @@ def txn_form(request, txn_type, txn=None):
|
||||
form = utils.make_txn_form_from_model(txn_type, txn)
|
||||
else:
|
||||
form = TransactionForm()
|
||||
form.debit_records.append(RecordForm())
|
||||
form.credit_records.append(RecordForm())
|
||||
form.transaction = txn
|
||||
form.txn_type = txn_type
|
||||
new_record_context = {"record": RecordForm(),
|
||||
|
Loading…
Reference in New Issue
Block a user