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

Checks that item_data is a dict before attempting to inspect it as one #3440

Merged
merged 1 commit into from
Mar 30, 2015
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
18 changes: 10 additions & 8 deletions kalite/topic_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,16 @@ def smart_translate_item_data(item_data):
item_data and translates only the content field.

"""
if 'content' in item_data:
item_data['content'] = _(item_data['content']) if item_data['content'] else ""

for field, field_data in item_data.iteritems():
if isinstance(field_data, dict):
item_data[field] = smart_translate_item_data(field_data)
elif isinstance(field_data, list):
item_data[field] = map(smart_translate_item_data, field_data)
if isinstance(item_data, dict):
if 'content' in item_data:
item_data['content'] = _(item_data['content']) if item_data['content'] else ""

for field, field_data in item_data.iteritems():
if isinstance(field_data, dict):
item_data[field] = smart_translate_item_data(field_data)
elif isinstance(field_data, list):
item_data[field] = map(smart_translate_item_data, field_data)


return item_data

Expand Down