Handle Unicode for Incoming Keys

This commit is contained in:
Syed Hassan Raza
2014-11-10 07:08:04 +00:00
parent 7b36645eb2
commit b3e7516af7
2 changed files with 8 additions and 1 deletions

View File

@@ -55,7 +55,9 @@ class VideoStudentViewHandlers(object):
if dispatch == 'save_user_state':
for key in data:
if hasattr(self, key) and key in accepted_keys:
if type(key) == str:
key = unicode(key, "UTF8")
if hasattr(self, key.encode('utf8')) and key in accepted_keys:
if key in conversions:
value = conversions[key](data[key])
else:

View File

@@ -131,6 +131,7 @@ class TestVideo(BaseTestXmodule):
{'speed': 2.0},
{'saved_video_position': "00:00:10"},
{'transcript_language': 'uk'},
{'demoo<EFBFBD>': 'sample'}
]
for sample in data:
response = self.clients[self.users[0].username].post(
@@ -152,6 +153,10 @@ class TestVideo(BaseTestXmodule):
self.item_descriptor.handle_ajax('save_user_state', {'transcript_language': "uk"})
self.assertEqual(self.item_descriptor.transcript_language, 'uk')
response = self.item_descriptor.handle_ajax('save_user_state', {'demoo<EFBFBD>': "sample"})
self.assertEqual(json.loads(response)['success'], True)
def tearDown(self):
_clear_assets(self.item_descriptor.location)