Revised the documentation of the forms in the accounting application.

This commit is contained in:
依瑪貓 2020-08-09 21:20:58 +08:00
parent f64d72ea26
commit 7596935ca2

View File

@ -85,7 +85,7 @@ class RecordForm(forms.Form):
"""Validates the form globally. """Validates the form globally.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
errors = [] errors = []
if "id" in self.errors: if "id" in self.errors:
@ -105,7 +105,7 @@ class RecordForm(forms.Form):
"""Validates whether the transaction matches the transaction form. """Validates whether the transaction matches the transaction form.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
if "id" in self.errors: if "id" in self.errors:
return return
@ -126,7 +126,7 @@ class RecordForm(forms.Form):
"""Validates whether the account is a correct debit or credit account. """Validates whether the account is a correct debit or credit account.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
if "account" in self.errors: if "account" in self.errors:
return return
@ -150,7 +150,7 @@ class RecordForm(forms.Form):
as corresponding debit and credit records. as corresponding debit and credit records.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
if "id" in self.errors: if "id" in self.errors:
return return
@ -201,7 +201,7 @@ class TransactionForm(forms.Form):
"""Validates the form globally. """Validates the form globally.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
errors = [] errors = []
validators = [self._validate_has_debit_records, validators = [self._validate_has_debit_records,
@ -219,7 +219,7 @@ class TransactionForm(forms.Form):
"""Validates whether there is any debit record. """Validates whether there is any debit record.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
if self.txn_type == "income": if self.txn_type == "income":
return return
@ -237,7 +237,7 @@ class TransactionForm(forms.Form):
"""Validates whether there is any credit record. """Validates whether there is any credit record.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
if self.txn_type == "expense": if self.txn_type == "expense":
return return
@ -256,7 +256,7 @@ class TransactionForm(forms.Form):
consistent. consistent.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
if self.txn_type != "transfer": if self.txn_type != "transfer":
return return
@ -341,7 +341,7 @@ class AccountForm(forms.Form):
"""Validates the form globally. """Validates the form globally.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
errors = [] errors = []
validators = [self._validate_code_not_under_myself, validators = [self._validate_code_not_under_myself,
@ -360,7 +360,7 @@ class AccountForm(forms.Form):
"""Validates whether the code is under itself. """Validates whether the code is under itself.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
if self.account is None: if self.account is None:
return return
@ -380,7 +380,7 @@ class AccountForm(forms.Form):
"""Validates whether the code is unique. """Validates whether the code is unique.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
if "code" not in self.data: if "code" not in self.data:
return return
@ -401,7 +401,7 @@ class AccountForm(forms.Form):
"""Validates whether the parent account exists. """Validates whether the parent account exists.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
if "code" not in self.data: if "code" not in self.data:
return return
@ -421,7 +421,7 @@ class AccountForm(forms.Form):
"""Validates whether the codes of the descendants will be too long. """Validates whether the codes of the descendants will be too long.
Raises: Raises:
ValidationError: When the validation fails. forms.ValidationError: When the validation fails.
""" """
if "code" not in self.data: if "code" not in self.data:
return return