@@ -11,7 +11,7 @@ from django.urls import resolve
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import ugettext_lazy
|
||||
from search.search_engine_base import SearchEngine
|
||||
from six import add_metaclass
|
||||
from six import add_metaclass, string_types
|
||||
|
||||
from contentstore.course_group_config import GroupConfiguration
|
||||
from course_modes.models import CourseMode
|
||||
@@ -621,7 +621,7 @@ class CourseAboutSearchIndexer(object):
|
||||
if section_content:
|
||||
if about_information.index_flags & AboutInfo.ANALYSE:
|
||||
analyse_content = section_content
|
||||
if isinstance(section_content, basestring):
|
||||
if isinstance(section_content, string_types):
|
||||
analyse_content = strip_html_content_to_text(section_content)
|
||||
course_info['content'][about_information.property_name] = analyse_content
|
||||
if about_information.index_flags & AboutInfo.PROPERTY:
|
||||
|
||||
@@ -7,6 +7,7 @@ from __future__ import absolute_import
|
||||
import urllib
|
||||
from uuid import uuid4
|
||||
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
@@ -222,7 +223,7 @@ def create_xblock(parent_locator, user, category, display_name, boilerplate=None
|
||||
|
||||
# TODO need to fix components that are sending definition_data as strings, instead of as dicts
|
||||
# For now, migrate them into dicts here.
|
||||
if isinstance(data, basestring):
|
||||
if isinstance(data, six.string_types):
|
||||
data = {'data': data}
|
||||
|
||||
created_block = store.create_child(
|
||||
|
||||
@@ -17,7 +17,7 @@ def _has_non_ascii_characters(data_string):
|
||||
"""
|
||||
Check if provided string contains non ascii characters
|
||||
|
||||
:param data_string: basestring or unicode object
|
||||
:param data_string: str or unicode object
|
||||
"""
|
||||
try:
|
||||
data_string.encode('ascii')
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<%page expression_filter="h"/>
|
||||
<%! from openedx.core.djangolib.markup import HTML %>
|
||||
<%!
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
import six
|
||||
%>
|
||||
<%
|
||||
def is_radio_input(choice_id):
|
||||
return input_type == 'radio' and ((isinstance(value, basestring) and (choice_id == value)) or (
|
||||
not isinstance(value, basestring) and choice_id in value
|
||||
return input_type == 'radio' and ((isinstance(value, six.string_types) and (choice_id == value)) or (
|
||||
not isinstance(value, six.string_types) and choice_id in value
|
||||
))
|
||||
%>
|
||||
<div class="choicegroup capa_inputtype" id="inputtype_${id}">
|
||||
|
||||
@@ -57,12 +57,12 @@ class AssetMetadata(object):
|
||||
EXPORTED_ASSET_FILENAME = u'assets.xml'
|
||||
|
||||
@contract(asset_id='AssetKey',
|
||||
pathname='basestring|None', internal_name='basestring|None',
|
||||
locked='bool|None', contenttype='basestring|None',
|
||||
thumbnail='basestring|None', fields='dict|None',
|
||||
curr_version='basestring|None', prev_version='basestring|None',
|
||||
created_by='int|long|None', created_by_email='basestring|None', created_on='datetime|None',
|
||||
edited_by='int|long|None', edited_by_email='basestring|None', edited_on='datetime|None')
|
||||
pathname='str|None', internal_name='str|None',
|
||||
locked='bool|None', contenttype='str|None',
|
||||
thumbnail='str|None', fields='dict|None',
|
||||
curr_version='str|None', prev_version='str|None',
|
||||
created_by='int|long|None', created_by_email='str|None', created_on='datetime|None',
|
||||
edited_by='int|long|None', edited_by_email='str|None', edited_on='datetime|None')
|
||||
def __init__(self, asset_id,
|
||||
pathname=None, internal_name=None,
|
||||
locked=None, contenttype=None,
|
||||
|
||||
@@ -237,7 +237,7 @@ class LibraryContentModule(LibraryContentFields, XModule, StudioEditableModule):
|
||||
Function that handles the actual publishing. Must have
|
||||
the signature:
|
||||
|
||||
<'removed'|'assigned'> -> result:T -> removed:T -> reason:basestring -> None
|
||||
<'removed'|'assigned'> -> result:T -> removed:T -> reason:str -> None
|
||||
|
||||
Where T is a collection of block_keys as returned by
|
||||
`format_block_keys`.
|
||||
|
||||
@@ -603,7 +603,7 @@ class ModuleStoreAssetBase(object):
|
||||
return mdata
|
||||
|
||||
@contract(
|
||||
course_key='CourseKey', asset_type='None | basestring',
|
||||
course_key='CourseKey', asset_type='None | str',
|
||||
start='int | None', maxresults='int | None', sort='tuple(str,int) | None'
|
||||
)
|
||||
def get_all_asset_metadata(self, course_key, asset_type, start=0, maxresults=-1, sort=None, **kwargs):
|
||||
|
||||
@@ -9,6 +9,8 @@ from __future__ import absolute_import
|
||||
from importlib import import_module
|
||||
import gettext
|
||||
import logging
|
||||
|
||||
import six
|
||||
from pkg_resources import resource_filename
|
||||
import re
|
||||
|
||||
@@ -250,7 +252,7 @@ def create_modulestore_instance(
|
||||
|
||||
FUNCTION_KEYS = ['render_template']
|
||||
for key in FUNCTION_KEYS:
|
||||
if key in _options and isinstance(_options[key], basestring):
|
||||
if key in _options and isinstance(_options[key], six.string_types):
|
||||
_options[key] = load_function(_options[key])
|
||||
|
||||
request_cache = DEFAULT_REQUEST_CACHE
|
||||
|
||||
@@ -495,7 +495,7 @@ class MixedModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase):
|
||||
return store.find_asset_metadata(asset_key, **kwargs)
|
||||
|
||||
@strip_key
|
||||
@contract(course_key='CourseKey', asset_type='None | basestring', start=int, maxresults=int, sort='tuple|None')
|
||||
@contract(course_key='CourseKey', asset_type='None | str', start=int, maxresults=int, sort='tuple|None')
|
||||
def get_all_asset_metadata(self, course_key, asset_type, start=0, maxresults=-1, sort=None, **kwargs):
|
||||
"""
|
||||
Returns a list of static assets for a course.
|
||||
|
||||
@@ -8,23 +8,23 @@ import traceback
|
||||
|
||||
import laboratory
|
||||
import rules
|
||||
from bridgekeeper.rules import Rule, EMPTY
|
||||
from course_modes.models import CourseMode
|
||||
import six
|
||||
from bridgekeeper.rules import EMPTY, Rule
|
||||
from django.conf import settings
|
||||
from django.db.models import Q
|
||||
from opaque_keys.edx.django.models import CourseKeyField
|
||||
from opaque_keys.edx.keys import CourseKey, UsageKey
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from student.models import CourseEnrollment, CourseAccessRole
|
||||
from xblock.core import XBlock
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from student.models import CourseAccessRole, CourseEnrollment
|
||||
from xmodule.course_module import CourseDescriptor
|
||||
from xmodule.error_module import ErrorDescriptor
|
||||
from xmodule.x_module import XModule
|
||||
|
||||
|
||||
from .access import has_access
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class HasStaffAccessToContent(Rule):
|
||||
course_key = instance
|
||||
elif isinstance(instance, UsageKey):
|
||||
course_key = instance.course_key
|
||||
elif isinstance(instance, basestring):
|
||||
elif isinstance(instance, six.string_types):
|
||||
course_key = CourseKey.from_string(instance)
|
||||
|
||||
return self.filter(user, CourseOverview.objects.filter(id=course_key)).exists()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
<%!
|
||||
import urllib
|
||||
import six
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import ungettext
|
||||
@@ -149,7 +150,7 @@ from util.course import get_link_for_about_page, get_encoded_course_sharing_utm_
|
||||
% endif
|
||||
</span>
|
||||
% else:
|
||||
% if isinstance(course_date, basestring):
|
||||
% if isinstance(course_date, six.string_types):
|
||||
<span class="info-date-block">${container_string.format(date=course_date)}</span>
|
||||
% elif course_date is not None:
|
||||
<span class="info-date-block localized-datetime" data-language="${user_language}" data-timezone="${user_timezone}" data-datetime="${course_date.strftime('%Y-%m-%dT%H:%M:%S%z')}" data-format=${format} data-string="${container_string}"></span>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from openedx.core.djangolib.js_utils import dump_js_escaped_json
|
||||
from eventtracking import tracker
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
import six
|
||||
%>
|
||||
<%
|
||||
user_metadata = {
|
||||
@@ -59,7 +60,7 @@ if course_key:
|
||||
|
||||
if not course_id:
|
||||
user_metadata['course_id'] = unicode(course_key)
|
||||
elif isinstance(course_key, basestring):
|
||||
elif isinstance(course_key, six.string_types):
|
||||
user_metadata['course_id'] = course_key
|
||||
|
||||
%>
|
||||
|
||||
@@ -127,7 +127,7 @@ class CourseDiscussionSettingsTest(ModuleStoreTestCase):
|
||||
def test_invalid_data_types(self):
|
||||
exception_msg_template = "Incorrect field type for `{}`. Type must be `{}`"
|
||||
fields = [
|
||||
{'name': 'division_scheme', 'type': basestring},
|
||||
{'name': 'division_scheme', 'type': six.string_types[0]},
|
||||
{'name': 'always_divide_inline_discussions', 'type': bool},
|
||||
{'name': 'divided_discussions', 'type': list}
|
||||
]
|
||||
|
||||
@@ -153,10 +153,11 @@ def set_course_discussion_settings(course_key, **kwargs):
|
||||
A CourseDiscussionSettings object.
|
||||
"""
|
||||
fields = {
|
||||
'division_scheme': basestring,
|
||||
'division_scheme': six.string_types[0],
|
||||
'always_divide_inline_discussions': bool,
|
||||
'divided_discussions': list,
|
||||
}
|
||||
|
||||
course_discussion_settings = get_course_discussion_settings(course_key)
|
||||
for field, field_type in fields.items():
|
||||
if field in kwargs:
|
||||
|
||||
Reference in New Issue
Block a user