Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up strings in the ErrorModule #2432

Merged
merged 1 commit into from
Feb 3, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions common/lib/xmodule/xmodule/error_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ def get_html(self):
def _construct(cls, system, contents, error_msg, location):
location = Location(location)

if error_msg is None:
# this string is not marked for translation because we don't have
# access to the user context, and this will only be seen by staff
error_msg = 'Error not available'

if location.category == 'error':
location = location.replace(
# Pick a unique url_name -- the sha1 hash of the contents.
Expand All @@ -97,7 +102,6 @@ def _construct(cls, system, contents, error_msg, location):
field_data = DictFieldData({
'error_msg': str(error_msg),
'contents': contents,
'display_name': 'Error: ' + location.url(),
'location': location,
'category': 'error'
})
Expand Down Expand Up @@ -125,7 +129,7 @@ def from_json(cls, json_data, system, location, error_msg='Error not available')
)

@classmethod
def from_descriptor(cls, descriptor, error_msg='Error not available'):
def from_descriptor(cls, descriptor, error_msg=None):
return cls._construct(
descriptor.runtime,
str(descriptor),
Expand All @@ -135,7 +139,7 @@ def from_descriptor(cls, descriptor, error_msg='Error not available'):

@classmethod
def from_xml(cls, xml_data, system, id_generator, # pylint: disable=arguments-differ
error_msg='Error not available'):
error_msg=None):
'''Create an instance of this descriptor from the supplied data.

Does not require that xml_data be parseable--just stores it and exports
Expand All @@ -154,7 +158,7 @@ def from_xml(cls, xml_data, system, id_generator, # pylint: disable=arguments-d
if error_node is not None:
error_msg = error_node.text
else:
error_msg = 'Error not available'
error_msg = None

except etree.XMLSyntaxError:
# Save the error to display later--overrides other problems
Expand Down