Added the set_multi_lingual_attr() utility function in the Mia core application.

This commit is contained in:
依瑪貓 2020-07-21 21:21:43 +08:00
parent 248ebe8774
commit 8d2d4c39b6

View File

@ -104,6 +104,18 @@ def get_multi_lingual_attr(model, name, default=None):
return getattr(model, name + Language.default().db)
def set_multi_lingual_attr(model, name, value):
"""Sets a multi-lingual attribute of a data model.
Args:
model (object): The data model.
name (str): The attribute name.
value (any): The new value
"""
language = Language.current()
setattr(model, name + language.db, value)
def get_multi_lingual_search(attr, query):
"""Returns the query condition on a multi-lingual attribute.