From ebb7c06f919b3075cdad032ffb96c20d29605feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Tue, 21 Jul 2020 21:23:54 +0800 Subject: [PATCH] Applied the set_multi_lingual_attr() utility function to the titles of the accounts and the names of the countries. --- accounting/models.py | 10 +++------- mia_core/models.py | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/accounting/models.py b/accounting/models.py index 947c890..74e491c 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -23,7 +23,7 @@ from django.db import models from django.urls import reverse from mia_core.templatetags.mia_core import smart_month -from mia_core.utils import get_multi_lingual_attr +from mia_core.utils import get_multi_lingual_attr, set_multi_lingual_attr class Account(models.Model): @@ -55,17 +55,13 @@ class Account(models.Model): """Returns the string representation of this account.""" return self.code.__str__() + " " + self.title - _title = None - @property def title(self): - if self._title is None: - self._title = get_multi_lingual_attr(self, "title") - return self._title + return get_multi_lingual_attr(self, "title") @title.setter def title(self, value): - self._title = value + set_multi_lingual_attr(self, "title", value) _url = None diff --git a/mia_core/models.py b/mia_core/models.py index d725ba8..6697077 100644 --- a/mia_core/models.py +++ b/mia_core/models.py @@ -21,7 +21,7 @@ from django.db import models -from mia_core.utils import get_multi_lingual_attr +from mia_core.utils import get_multi_lingual_attr, set_multi_lingual_attr class Country(models.Model): @@ -50,17 +50,13 @@ class Country(models.Model): """Returns the string representation of this country.""" return self.code.__str__() + " " + self.name.__str__() - _name = None - @property def name(self): - if self._name is None: - self._name = get_multi_lingual_attr(self, "name", "en") - return self._name + return get_multi_lingual_attr(self, "name", "en") @name.setter def name(self, value): - self._name = value + set_multi_lingual_attr(self, "name", value) class Meta: db_table = "countries"