Commit 3c30d07d by Őry Máté

common: handle missing params for HumanReadableObject.get_*_text()

parent 6474d40a
...@@ -375,12 +375,22 @@ class HumanReadableObject(object): ...@@ -375,12 +375,22 @@ class HumanReadableObject(object):
def get_admin_text(self): def get_admin_text(self):
if self.admin_text_template == "": if self.admin_text_template == "":
return "" return ""
try:
return _(self.admin_text_template) % self.params return _(self.admin_text_template) % self.params
except KeyError:
logger.exception("Can't render admin_text_template '%s' %% %s",
self.admin_text_template, unicode(self.params))
return self.get_user_text()
def get_user_text(self): def get_user_text(self):
if self.user_text_template == "": if self.user_text_template == "":
return "" return ""
try:
return _(self.user_text_template) % self.params return _(self.user_text_template) % self.params
except KeyError:
logger.exception("Can't render user_text_template '%s' %% %s",
self.user_text_template, unicode(self.params))
return self.user_text_template
def to_dict(self): def to_dict(self):
return {"user_text_template": self.user_text_template, return {"user_text_template": self.user_text_template,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment