Skip to content

Commit

Permalink
Checks that itemn_data is a dict before attempting to inspect it as o…
Browse files Browse the repository at this point in the history
…ne in smart_trnaslate_item_data
  • Loading branch information
rtibbles committed Mar 30, 2015
1 parent ed17b3a commit 82fe841
Showing 1 changed file with 10 additions and 8 deletions.
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

0 comments on commit 82fe841

Please sign in to comment.