diff --git a/cms/djangoapps/contentstore/tasks.py b/cms/djangoapps/contentstore/tasks.py index 1c125f0156..2e247e1042 100644 --- a/cms/djangoapps/contentstore/tasks.py +++ b/cms/djangoapps/contentstore/tasks.py @@ -199,7 +199,7 @@ def enqueue_async_migrate_transcripts_tasks(course_keys, 'command_run': command_run } group([ - async_migrate_transcript.s(unicode(course_key), **kwargs) + async_migrate_transcript.s(text_type(course_key), **kwargs) for course_key in course_keys ])() @@ -266,7 +266,7 @@ def async_migrate_transcript(self, course_key, **kwargs): # pylint: disable=un all_transcripts.update({'en': video.sub}) sub_tasks = [] - video_location = unicode(video.location) + video_location = text_type(video.location) for lang in all_transcripts: sub_tasks.append(async_migrate_transcript_subtask.s( video_location, revision, lang, force_update, **kwargs diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index 1228b724e2..ed75ccd25b 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -1,6 +1,7 @@ from __future__ import absolute_import import logging +import six from django.conf import settings from django.contrib.auth.decorators import login_required @@ -130,9 +131,10 @@ def container_handler(request, usage_key_string): assert unit is not None, "Could not determine unit page" subsection = get_parent_xblock(unit) - assert subsection is not None, "Could not determine parent subsection from unit " + unicode(unit.location) + assert subsection is not None, "Could not determine parent subsection from unit " + six.text_type( + unit.location) section = get_parent_xblock(subsection) - assert section is not None, "Could not determine ancestor section from unit " + unicode(unit.location) + assert section is not None, "Could not determine ancestor section from unit " + six.text_type(unit.location) # Fetch the XBlock info for use by the container page. Note that it includes information # about the block's ancestors and siblings for use by the Unit Outline. diff --git a/cms/djangoapps/contentstore/views/library.py b/cms/djangoapps/contentstore/views/library.py index f26b3dca93..a9bdc0dace 100644 --- a/cms/djangoapps/contentstore/views/library.py +++ b/cms/djangoapps/contentstore/views/library.py @@ -106,13 +106,13 @@ def _display_library(library_key_string, request): if not has_studio_read_access(request.user, library_key): log.exception( u"User %s tried to access library %s without permission", - request.user.username, unicode(library_key) + request.user.username, text_type(library_key) ) raise PermissionDenied() library = modulestore().get_library(library_key) if library is None: - log.exception(u"Library %s not found", unicode(library_key)) + log.exception(u"Library %s not found", text_type(library_key)) raise Http404 response_format = 'html' @@ -132,7 +132,7 @@ def _list_libraries(request): lib_info = [ { "display_name": lib.display_name, - "library_key": unicode(lib.location.library_key), + "library_key": text_type(lib.location.library_key), } for lib in modulestore().get_libraries() if has_studio_read_access(request.user, lib.location.library_key) @@ -182,7 +182,7 @@ def _create_library(request): ) }) - lib_key_str = unicode(new_lib.location.library_key) + lib_key_str = text_type(new_lib.location.library_key) return JsonResponse({ 'url': reverse_library_url('library_handler', lib_key_str), 'library_key': lib_key_str, @@ -208,10 +208,10 @@ def library_blocks_view(library, user, response_format): prev_version = library.runtime.course_entry.structure['previous_version'] return JsonResponse({ "display_name": library.display_name, - "library_id": unicode(library.location.library_key), - "version": unicode(library.runtime.course_entry.course_key.version_guid), - "previous_version": unicode(prev_version) if prev_version else None, - "blocks": [unicode(x) for x in children], + "library_id": text_type(library.location.library_key), + "version": text_type(library.runtime.course_entry.course_key.version_guid), + "previous_version": text_type(prev_version) if prev_version else None, + "blocks": [text_type(x) for x in children], }) can_edit = has_studio_write_access(user, library.location.library_key) @@ -261,7 +261,7 @@ def manage_library_users(request, library_key_string): 'context_library': library, 'users': formatted_users, 'allow_actions': bool(user_perms & STUDIO_EDIT_ROLES), - 'library_key': unicode(library_key), + 'library_key': text_type(library_key), 'lib_users_url': reverse_library_url('manage_library_users', library_key_string), 'show_children_previews': library.show_children_previews }) diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 2c4694c691..68a26fb9ba 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -2,6 +2,7 @@ from __future__ import absolute_import import logging from functools import partial +import six from django.conf import settings from django.contrib.auth.decorators import login_required @@ -101,7 +102,7 @@ class PreviewModuleSystem(ModuleSystem): # pylint: disable=abstract-method def handler_url(self, block, handler_name, suffix='', query='', thirdparty=False): return reverse('preview_handler', kwargs={ - 'usage_key_string': unicode(block.scope_ids.usage_id), + 'usage_key_string': six.text_type(block.scope_ids.usage_id), 'handler': handler_name, 'suffix': suffix, }) + '?' + query @@ -166,7 +167,7 @@ def _preview_module_system(request, descriptor, field_data): wrap_xblock, 'PreviewRuntime', display_name_only=display_name_only, - usage_id_serializer=unicode, + usage_id_serializer=six.text_type, request_token=request_token(request) ), @@ -180,7 +181,7 @@ def _preview_module_system(request, descriptor, field_data): partial( wrap_xblock_aside, 'PreviewRuntime', - usage_id_serializer=unicode, + usage_id_serializer=six.text_type, request_token=request_token(request) ) ] diff --git a/cms/templates/checklists.html b/cms/templates/checklists.html index 6c6bf24643..7bc7fd0f01 100644 --- a/cms/templates/checklists.html +++ b/cms/templates/checklists.html @@ -2,6 +2,8 @@ <%inherit file="base.html" /> <%def name="online_help_token()"><% return "files" %> <%! + import six + from cms.djangoapps.contentstore import utils from cms.djangoapps.contentstore.config.waffle_utils import should_show_checklists_quality from django.core.urlresolvers import reverse @@ -38,7 +40,7 @@ <%static:studiofrontend entry="courseHealthCheck"> <% - course_key = unicode(context_course.id) + course_key = six.text_type(context_course.id) certificates_url = '' if has_certificates_enabled(context_course): certificates_url = utils.reverse_course_url('certificates_list_handler', course_key) diff --git a/cms/templates/course_outline.html b/cms/templates/course_outline.html index 5507ed75fa..a321f75627 100644 --- a/cms/templates/course_outline.html +++ b/cms/templates/course_outline.html @@ -3,6 +3,8 @@ <%def name="online_help_token()"><% return "develop_course" %> <%! import logging +import six + from cms.djangoapps.contentstore.config.waffle_utils import should_show_checklists_quality from util.date_utils import get_default_time_display from django.utils.translation import ugettext as _ @@ -185,7 +187,7 @@ from django.core.urlresolvers import reverse }, "enable_quality": ${should_show_checklists_quality(context_course.id) | n, dump_js_escaped_json}, "links": { - "settings": ${reverse('settings_handler', kwargs={'course_key_string': unicode(course_key)})| n, dump_js_escaped_json} + "settings": ${reverse('settings_handler', kwargs={'course_key_string': six.text_type(course_key)})| n, dump_js_escaped_json} } } diff --git a/cms/templates/export_git.html b/cms/templates/export_git.html index 65c8c3e08b..d18a231862 100644 --- a/cms/templates/export_git.html +++ b/cms/templates/export_git.html @@ -3,6 +3,8 @@ <%namespace name='static' file='static_content.html'/> <%! + import six + from django.urls import reverse from django.utils.translation import ugettext as _ %> @@ -39,7 +41,7 @@ % else: