From f686e7d0b98540d6ae89fdad9d4e23a1b12e1446 Mon Sep 17 00:00:00 2001 From: Waheed Ahmed Date: Mon, 18 Aug 2014 13:26:30 +0500 Subject: [PATCH] Passed cls=EdxJSONEncoder on json.dumps to fix save, edit and import. STUD-2096 --- cms/djangoapps/contentstore/views/item.py | 4 +- cms/templates/widgets/metadata-edit.html | 3 +- .../xmodule/modulestore/tests/test_mongo.py | 51 ++++++++++++- common/test/acceptance/pages/studio/export.py | 7 ++ .../tests/test_studio_with_ora_component.py | 74 +++++++++++++++++++ 5 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 common/test/acceptance/tests/test_studio_with_ora_component.py diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index 948a5a636b..2959ba1391 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -24,7 +24,7 @@ from xblock.fragment import Fragment import xmodule from xmodule.tabs import StaticTab, CourseTabList -from xmodule.modulestore import ModuleStoreEnum, PublishState +from xmodule.modulestore import ModuleStoreEnum, PublishState, EdxJSONEncoder from xmodule.modulestore.django import modulestore from xmodule.modulestore.exceptions import ItemNotFoundError, InvalidLocationError from xmodule.modulestore.inheritance import own_metadata @@ -397,7 +397,7 @@ def _save_xblock(user, xblock, data=None, children=None, metadata=None, nullout= modulestore().publish(xblock.location, user.id) # Note that children aren't being returned until we have a use case. - return JsonResponse(result) + return JsonResponse(result, encoder=EdxJSONEncoder) @login_required diff --git a/cms/templates/widgets/metadata-edit.html b/cms/templates/widgets/metadata-edit.html index 3af94c4633..3404bcaf21 100644 --- a/cms/templates/widgets/metadata-edit.html +++ b/cms/templates/widgets/metadata-edit.html @@ -5,6 +5,7 @@ import hashlib import copy import json + from xmodule.modulestore import EdxJSONEncoder hlskey = hashlib.md5(module.location.to_deprecated_string().encode('utf-8')).hexdigest() %> @@ -33,4 +34,4 @@ <%include file="source-edit.html" /> % endif -
+