Applied the set_multi_lingual_attr() utility function to the titles of the accounts and the names of the countries.
This commit is contained in:
parent
8d2d4c39b6
commit
ebb7c06f91
@ -23,7 +23,7 @@ from django.db import models
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from mia_core.templatetags.mia_core import smart_month
|
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):
|
class Account(models.Model):
|
||||||
@ -55,17 +55,13 @@ class Account(models.Model):
|
|||||||
"""Returns the string representation of this account."""
|
"""Returns the string representation of this account."""
|
||||||
return self.code.__str__() + " " + self.title
|
return self.code.__str__() + " " + self.title
|
||||||
|
|
||||||
_title = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def title(self):
|
def title(self):
|
||||||
if self._title is None:
|
return get_multi_lingual_attr(self, "title")
|
||||||
self._title = get_multi_lingual_attr(self, "title")
|
|
||||||
return self._title
|
|
||||||
|
|
||||||
@title.setter
|
@title.setter
|
||||||
def title(self, value):
|
def title(self, value):
|
||||||
self._title = value
|
set_multi_lingual_attr(self, "title", value)
|
||||||
|
|
||||||
_url = None
|
_url = None
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
from django.db import models
|
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):
|
class Country(models.Model):
|
||||||
@ -50,17 +50,13 @@ class Country(models.Model):
|
|||||||
"""Returns the string representation of this country."""
|
"""Returns the string representation of this country."""
|
||||||
return self.code.__str__() + " " + self.name.__str__()
|
return self.code.__str__() + " " + self.name.__str__()
|
||||||
|
|
||||||
_name = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
if self._name is None:
|
return get_multi_lingual_attr(self, "name", "en")
|
||||||
self._name = get_multi_lingual_attr(self, "name", "en")
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, value):
|
def name(self, value):
|
||||||
self._name = value
|
set_multi_lingual_attr(self, "name", value)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "countries"
|
db_table = "countries"
|
||||||
|
Loading…
Reference in New Issue
Block a user