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" %>%def>
<%!
+ 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" %>%def>
<%!
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}
}
}
%static:studiofrontend>
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:
-
+ ${_("Export to Git")}
diff --git a/cms/templates/manage_users.html b/cms/templates/manage_users.html
index 50b7a9e3df..580a313dc3 100644
--- a/cms/templates/manage_users.html
+++ b/cms/templates/manage_users.html
@@ -1,5 +1,8 @@
+## xss-lint: disable=mako-missing-default
<%inherit file="base.html" />
<%!
+import six
+
from django.utils.translation import ugettext as _
from django.urls import reverse
@@ -106,6 +109,7 @@ from openedx.core.djangolib.js_utils import (
% if show_transfer_ownership_hint:
${_("Transferring Ownership")}
+ # xss-lint: disable=python-wrap-html
${_("Every course must have an Admin. If you are the Admin and you want to transfer ownership of the course, click Add admin access to make another user the Admin, then ask that user to remove you from the Course Team list.")}
% endif
@@ -117,9 +121,11 @@ from openedx.core.djangolib.js_utils import (
<%block name="requirejs">
require(["js/factories/manage_users"], function(ManageCourseUsersFactory) {
ManageCourseUsersFactory(
+ // xss-lint: disable=mako-invalid-js-filter
"${context_course.display_name_with_default | h}",
${users | n, dump_js_escaped_json},
- "${reverse('course_team_handler', kwargs={'course_key_string': unicode(context_course.id), 'email': '@@EMAIL@@'}) | n, js_escaped_string}",
+ // xss-lint: disable=mako-invalid-js-filter
+ "${reverse('course_team_handler', kwargs={'course_key_string': six.text_type(context_course.id), 'email': '@@EMAIL@@'}) | n, js_escaped_string}",
${request.user.id | n, dump_js_escaped_json},
${allow_actions | n, dump_js_escaped_json}
);
diff --git a/common/lib/xmodule/xmodule/tests/test_vertical.py b/common/lib/xmodule/xmodule/tests/test_vertical.py
index 765450f17f..7ceb28eeef 100644
--- a/common/lib/xmodule/xmodule/tests/test_vertical.py
+++ b/common/lib/xmodule/xmodule/tests/test_vertical.py
@@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
from collections import namedtuple
import json
+import six
import ddt
from fs.memoryfs import MemoryFS
@@ -113,7 +114,7 @@ class VerticalBlockTestCase(BaseVerticalBlockTest):
Assert content has/hasn't all the bookmark info.
"""
assertion('bookmark_id', content)
- assertion('{},{}'.format(self.username, unicode(self.vertical.location)), content)
+ assertion('{},{}'.format(self.username, six.text_type(self.vertical.location)), content)
assertion('bookmarked', content)
assertion('show_bookmark_button', content)
diff --git a/lms/djangoapps/discussion/templates/discussion/discussion_board_js.template b/lms/djangoapps/discussion/templates/discussion/discussion_board_js.template
index 13b661d541..b23082c49d 100644
--- a/lms/djangoapps/discussion/templates/discussion/discussion_board_js.template
+++ b/lms/djangoapps/discussion/templates/discussion/discussion_board_js.template
@@ -1,6 +1,8 @@
## mako
<%!
+import six
+
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
%>
@@ -46,7 +48,7 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
$(function() {
require(['discussion/js/discussion_board_factory'], function (DiscussionBoardFactory) {
DiscussionBoardFactory({
- courseId: '${unicode(course.id) | n, js_escaped_string}',
+ courseId: '${six.text_type(course.id) | n, js_escaped_string}',
$el: $(".discussion-board"),
rootUrl: '${root_url | n, js_escaped_string}',
userInfo: ${user_info | n, dump_js_escaped_json},
diff --git a/lms/djangoapps/discussion/templates/discussion/discussion_profile_page.html b/lms/djangoapps/discussion/templates/discussion/discussion_profile_page.html
index ca3bdf9059..4a58170257 100644
--- a/lms/djangoapps/discussion/templates/discussion/discussion_profile_page.html
+++ b/lms/djangoapps/discussion/templates/discussion/discussion_profile_page.html
@@ -6,6 +6,8 @@
<%!
import json
+import six
+
from django.utils.translation import ugettext as _, ungettext
from django.template.defaultfilters import escapejs
from django.urls import reverse
@@ -19,7 +21,7 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
<%static:require_module module_name="discussion/js/discussion_profile_page_factory" class_name="DiscussionProfilePageFactory">
profile_page_context = {
'courseSettings': ${course_settings | n, dump_js_escaped_json},
- 'courseId': '${unicode(course.id) | n, js_escaped_string}',
+ 'courseId': '${six.text_type(course.id) | n, js_escaped_string}',
'courseName': '${course.display_name_with_default | n, js_escaped_string}',
'contentInfo': ${annotated_content_info | n, dump_js_escaped_json},
'userInfo': ${user_info | n, dump_js_escaped_json},
diff --git a/lms/djangoapps/teams/templates/teams/teams.html b/lms/djangoapps/teams/templates/teams/teams.html
index 9482ea8b8d..5b0a885a75 100644
--- a/lms/djangoapps/teams/templates/teams/teams.html
+++ b/lms/djangoapps/teams/templates/teams/teams.html
@@ -4,6 +4,8 @@
<%! import json %>
<%!
+import six
+
from django.utils.translation import ugettext as _
from openedx.core.djangolib.js_utils import (
dump_js_escaped_json, js_escaped_string
@@ -39,7 +41,7 @@ from openedx.core.djangolib.js_utils import (
<%static:require_module module_name="teams/js/teams_tab_factory" class_name="TeamsTabFactory">
TeamsTabFactory({
- courseID: '${unicode(course.id) | n, js_escaped_string}',
+ courseID: '${six.text_type(course.id) | n, js_escaped_string}',
topics: ${topics | n, dump_js_escaped_json},
userInfo: ${user_info | n, dump_js_escaped_json},
topicUrl: '${topic_url | n, js_escaped_string}',
diff --git a/lms/templates/courseware/course_about.html b/lms/templates/courseware/course_about.html
index c1412399f0..3eea1aedc5 100644
--- a/lms/templates/courseware/course_about.html
+++ b/lms/templates/courseware/course_about.html
@@ -273,7 +273,7 @@ from six import string_types
%endif
% if pre_requisite_courses:
- <% prc_target = reverse('about_course', args=[unicode(pre_requisite_courses[0]['key'])]) %>
+ <% prc_target = reverse('about_course', args=[text_type(pre_requisite_courses[0]['key'])]) %>
diff --git a/openedx/features/course_bookmarks/templates/course_bookmarks/course_bookmarks_js.template b/openedx/features/course_bookmarks/templates/course_bookmarks/course_bookmarks_js.template
index 348670d3d0..232ff21a7c 100644
--- a/openedx/features/course_bookmarks/templates/course_bookmarks/course_bookmarks_js.template
+++ b/openedx/features/course_bookmarks/templates/course_bookmarks/course_bookmarks_js.template
@@ -1,6 +1,7 @@
## mako
<%!
+import six
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
%>
@@ -8,7 +9,7 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
require(['course_bookmarks/js/course_bookmarks_factory'], function (CourseBookmarksFactory) {
CourseBookmarksFactory({
$el: $(".course-bookmarks"),
- courseId: '${unicode(course.id) | n, js_escaped_string}',
+ courseId: '${six.text_type(course.id) | n, js_escaped_string}',
bookmarksApiUrl: '${bookmarks_api_url | n, js_escaped_string}',
});
});
diff --git a/themes/edx.org/lms/templates/dashboard.html b/themes/edx.org/lms/templates/dashboard.html
index c582fc49e9..44dcd846d1 100644
--- a/themes/edx.org/lms/templates/dashboard.html
+++ b/themes/edx.org/lms/templates/dashboard.html
@@ -5,6 +5,7 @@
<%!
import json
import pytz
+import six
from courseware.context_processor import user_timezone_locale_prefs
from datetime import datetime, timedelta
from django.utils import timezone
@@ -196,7 +197,7 @@ from student.models import CourseEnrollment
is_course_blocked = (session_id in block_courses)
course_verification_status = verification_status_by_course.get(session_id, {})
course_requirements = courses_requirements_not_met.get(session_id)
- related_programs = inverted_programs.get(unicode(entitlement.course_uuid if is_unfulfilled_entitlement else session_id))
+ related_programs = inverted_programs.get(six.text_type(entitlement.course_uuid if is_unfulfilled_entitlement else session_id))
show_consent_link = (session_id in consent_required_courses)
course_overview = enrollment.course_overview
resume_button_url = resume_button_urls[dashboard_index]
diff --git a/themes/stanford-style/lms/templates/register-form.html b/themes/stanford-style/lms/templates/register-form.html
index 3bcf7c9992..735f48df38 100644
--- a/themes/stanford-style/lms/templates/register-form.html
+++ b/themes/stanford-style/lms/templates/register-form.html
@@ -1,5 +1,7 @@
+## xss-lint: disable=mako-missing-default
<%!
import third_party_auth
+import six
from third_party_auth import pipeline, provider
from django.utils.translation import ugettext as _
from django_countries import countries
@@ -46,6 +48,7 @@ from student.models import UserProfile
${_('Create your own {platform_name} account below').format(platform_name=platform_name)}
+ # xss-lint: disable=python-wrap-html
${_('Required fields are noted by bold text and an asterisk (*).')}
@@ -54,6 +57,7 @@ from student.models import UserProfile
## Translators: selected_provider is the name of an external, third-party user authentication service (like Google or LinkedIn).
+ # xss-lint: disable=python-wrap-html, python-interpolate-html
${_("You've successfully signed in with {selected_provider}.").format(selected_provider='%s' % selected_provider)}
${_("We just need a little more information before you start learning with {platform_name}.").format(platform_name=settings.PLATFORM_NAME)}
@@ -64,6 +68,7 @@ from student.models import UserProfile
${_("Please complete the following fields to register for an account. ")}
+ # xss-lint: disable=python-wrap-html
${_('Required fields are noted by bold text and an asterisk (*).')}
@@ -164,7 +169,7 @@ from student.models import UserProfile
@@ -240,7 +245,9 @@ from student.models import UserProfile