Renamed the "default_currency" option to "default_currency_code".

This commit is contained in:
依瑪貓 2023-03-22 22:34:13 +08:00
parent 0ad2ac53dd
commit b673c7aeaf
4 changed files with 12 additions and 12 deletions

View File

@ -208,7 +208,7 @@ class RecurringForm(RecurringItemForm):
class OptionForm(FlaskForm): class OptionForm(FlaskForm):
"""The form to update the options.""" """The form to update the options."""
default_currency = StringField( default_currency_code = StringField(
filters=[strip_text], filters=[strip_text],
validators=[ validators=[
DataRequired(lazy_gettext("Please select the default currency.")), DataRequired(lazy_gettext("Please select the default currency.")),
@ -230,7 +230,7 @@ class OptionForm(FlaskForm):
:param obj: The currency object. :param obj: The currency object.
:return: None. :return: None.
""" """
obj.default_currency = self.default_currency.data obj.default_currency_code = self.default_currency_code.data
obj.default_ie_account_code = self.default_ie_account_code.data obj.default_ie_account_code = self.default_ie_account_code.data
obj.recurring_data = self.recurring.form.as_data obj.recurring_data = self.recurring.form.as_data

View File

@ -34,4 +34,4 @@ def default_currency_code() -> str:
:return: The default currency code. :return: The default currency code.
""" """
return options.default_currency return options.default_currency_code

View File

@ -43,13 +43,13 @@ First written: 2023/3/22
<input type="hidden" name="next" value="{{ request.args.next }}"> <input type="hidden" name="next" value="{{ request.args.next }}">
{% endif %} {% endif %}
<div class="form-floating mb-3"> <div class="form-floating mb-3">
<select id="accounting-default-currency" class="form-select {% if form.default_currency.errors %} is-invalid {% endif %}" name="default_currency"> <select id="accounting-default-currency" class="form-select {% if form.default_currency_code.errors %} is-invalid {% endif %}" name="default_currency_code">
{% for currency in accounting_currency_options() %} {% for currency in accounting_currency_options() %}
<option value="{{ currency.code }}" {% if currency.code == form.default_currency.data %} selected="selected" {% endif %}>{{ currency }}</option> <option value="{{ currency.code }}" {% if currency.code == form.default_currency_code.data %} selected="selected" {% endif %}>{{ currency }}</option>
{% endfor %} {% endfor %}
</select> </select>
<label class="form-label" for="accounting-default-currency">{{ A_("Default Currency") }}</label> <label class="form-label" for="accounting-default-currency">{{ A_("Default Currency") }}</label>
<div id="accounting-default-currency-error" class="invalid-feedback">{% if form.default_currency.errors %}{{ form.default_currency.errors[0] }}{% endif %}</div> <div id="accounting-default-currency-error" class="invalid-feedback">{% if form.default_currency_code.errors %}{{ form.default_currency_code.errors[0] }}{% endif %}</div>
</div> </div>
<div class="form-floating mb-3"> <div class="form-floating mb-3">

View File

@ -82,21 +82,21 @@ class Options:
"""Whether the options were modified.""" """Whether the options were modified."""
@property @property
def default_currency(self) -> str: def default_currency_code(self) -> str:
"""Returns the default currency code. """Returns the default currency code.
:return: The default currency code. :return: The default currency code.
""" """
return self.__get_option("default_currency", "USD") return self.__get_option("default_currency_code", "USD")
@default_currency.setter @default_currency_code.setter
def default_currency(self, value: str) -> None: def default_currency_code(self, value: str) -> None:
"""Sets the default currency code. """Sets the default currency code.
:param value: The default currency code. :param value: The default currency code.
:return: None. :return: None.
""" """
self.__set_option("default_currency", value) self.__set_option("default_currency_code", value)
@property @property
def default_currency_text(self) -> str: def default_currency_text(self) -> str:
@ -104,7 +104,7 @@ class Options:
:return: The text of the default currency code. :return: The text of the default currency code.
""" """
return str(db.session.get(Currency, self.default_currency)) return str(db.session.get(Currency, self.default_currency_code))
@property @property
def default_ie_account_code(self) -> str: def default_ie_account_code(self) -> str: