-Remove unicode and use six.text_type

This commit is contained in:
Ayub khan
2019-08-28 13:23:32 +05:00
parent 85f622f0e1
commit da9c71557b
26 changed files with 93 additions and 45 deletions

View File

@@ -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.

View File

@@ -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
})

View File

@@ -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)
)
]