Slight tweak to get_text

This commit is contained in:
Ned Batchelder
2014-05-20 12:02:17 -04:00
parent f3371643ee
commit 2c4fcb0c5b

View File

@@ -778,6 +778,13 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock):
json_choice = field.to_json(json_choice)
return json_choice
def get_text(value):
"""Localize a text value that might be None."""
if value is None:
return None
else:
return self.runtime.service(self, "i18n").ugettext(value)
metadata_fields = {}
# Only use the fields from this class, not mixins
@@ -788,9 +795,6 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock):
if field.scope != Scope.settings or field in self.non_editable_metadata_fields:
continue
def get_text(value):
return self.runtime.service(self, "i18n").ugettext(value) if value is not None else None
# gets the 'default_value' and 'explicitly_set' attrs
metadata_fields[field.name] = self.runtime.get_field_provenance(self, field)
metadata_fields[field.name]['field_name'] = field.name