Added the strip_form() utility to the Mia core application, and apply it to the transaction_store() view of the accounting application.
This commit is contained in:
parent
69e8eed33f
commit
1a27d87400
@ -34,7 +34,8 @@ from django.views.generic import RedirectView
|
|||||||
from mia_core.digest_auth import login_required
|
from mia_core.digest_auth import login_required
|
||||||
from mia_core.period import Period
|
from mia_core.period import Period
|
||||||
from mia_core.status import success_redirect, error_redirect
|
from mia_core.status import success_redirect, error_redirect
|
||||||
from mia_core.utils import Pagination, get_multi_lingual_search, UrlBuilder
|
from mia_core.utils import Pagination, get_multi_lingual_search, UrlBuilder, \
|
||||||
|
strip_form
|
||||||
from .models import Record, Transaction, Account, RecordSummary
|
from .models import Record, Transaction, Account, RecordSummary
|
||||||
from .utils import ReportUrl, get_cash_accounts, get_ledger_accounts, \
|
from .utils import ReportUrl, get_cash_accounts, get_ledger_accounts, \
|
||||||
find_imbalanced, find_order_holes, fill_transaction_from_form, \
|
find_imbalanced, find_order_holes, fill_transaction_from_form, \
|
||||||
@ -848,6 +849,7 @@ def transaction_store(request, txn_type, transaction=None):
|
|||||||
if transaction is None:
|
if transaction is None:
|
||||||
transaction = Transaction()
|
transaction = Transaction()
|
||||||
form = request.POST.dict()
|
form = request.POST.dict()
|
||||||
|
strip_form(form)
|
||||||
sort_form_transaction_records(form)
|
sort_form_transaction_records(form)
|
||||||
fill_transaction_from_form(transaction, form)
|
fill_transaction_from_form(transaction, form)
|
||||||
errors = {}
|
errors = {}
|
||||||
|
@ -43,6 +43,16 @@ def new_pk(cls):
|
|||||||
return id
|
return id
|
||||||
|
|
||||||
|
|
||||||
|
def strip_form(form):
|
||||||
|
"""Strips the values of a form. Empty strings are converted to None.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
form (dict[str]): The form.
|
||||||
|
"""
|
||||||
|
for key in form.keys():
|
||||||
|
form[key] = form[key].strip()
|
||||||
|
|
||||||
|
|
||||||
class Language:
|
class Language:
|
||||||
"""A language.
|
"""A language.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user