diff --git a/openedx/features/course_experience/__init__.py b/openedx/features/course_experience/__init__.py index 33202a2bae..386a3f41c3 100644 --- a/openedx/features/course_experience/__init__.py +++ b/openedx/features/course_experience/__init__.py @@ -1,11 +1,12 @@ """ Unified course experience settings and helper methods. """ +from __future__ import absolute_import + from django.utils.translation import ugettext as _ from openedx.core.djangoapps.util.user_messages import UserMessageCollection -from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, WaffleFlagNamespace, WaffleFlag - +from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, WaffleFlag, WaffleFlagNamespace # Namespace for course experience waffle flags. WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='course_experience') diff --git a/openedx/features/course_experience/course_tools.py b/openedx/features/course_experience/course_tools.py index fe1f45f261..23d1bb0135 100644 --- a/openedx/features/course_experience/course_tools.py +++ b/openedx/features/course_experience/course_tools.py @@ -1,6 +1,8 @@ """ Support for course tool plugins. """ +from __future__ import absolute_import + from openedx.core.lib.plugins import PluginManager # Stevedore extension point namespace @@ -70,7 +72,7 @@ class CourseToolsPluginManager(PluginManager): """ Returns the list of available course tools in their canonical order. """ - course_tools = cls.get_available_plugins().values() + course_tools = list(cls.get_available_plugins().values()) course_tools.sort(key=lambda course_tool: course_tool.title()) return course_tools @@ -80,4 +82,4 @@ class CourseToolsPluginManager(PluginManager): Returns the course tools applicable to the current user and course. """ course_tools = CourseToolsPluginManager.get_course_tools() - return filter(lambda tool: tool.is_enabled(request, course_key), course_tools) + return [tool for tool in course_tools if tool.is_enabled(request, course_key)] diff --git a/openedx/features/course_experience/plugins.py b/openedx/features/course_experience/plugins.py index e478a8b923..9b25ada0b1 100644 --- a/openedx/features/course_experience/plugins.py +++ b/openedx/features/course_experience/plugins.py @@ -3,6 +3,8 @@ Platform plugins to support the course experience. This includes any locally defined CourseTools. """ +from __future__ import absolute_import + from django.urls import reverse from django.utils.translation import ugettext as _ diff --git a/openedx/features/course_experience/urls.py b/openedx/features/course_experience/urls.py index 002d66b4af..f764e918e8 100644 --- a/openedx/features/course_experience/urls.py +++ b/openedx/features/course_experience/urls.py @@ -2,14 +2,16 @@ Defines URLs for the course experience. """ +from __future__ import absolute_import + from django.conf.urls import url from .views.course_dates import CourseDatesFragmentMobileView from .views.course_home import CourseHomeFragmentView, CourseHomeView from .views.course_outline import CourseOutlineFragmentView from .views.course_reviews import CourseReviewsView -from .views.course_updates import CourseUpdatesFragmentView, CourseUpdatesView from .views.course_sock import CourseSockFragmentView +from .views.course_updates import CourseUpdatesFragmentView, CourseUpdatesView from .views.latest_update import LatestUpdateFragmentView from .views.welcome_message import WelcomeMessageFragmentView, dismiss_welcome_message diff --git a/openedx/features/course_experience/utils.py b/openedx/features/course_experience/utils.py index f52a6479d1..01e636ba98 100644 --- a/openedx/features/course_experience/utils.py +++ b/openedx/features/course_experience/utils.py @@ -1,16 +1,19 @@ """ Common utilities for the course experience, including course outline. """ +from __future__ import absolute_import + from completion.models import BlockCompletion from django.utils.translation import ugettext as _ +from opaque_keys.edx.keys import CourseKey +from six.moves import range +from web_fragments.fragment import Fragment from lms.djangoapps.course_api.blocks.api import get_blocks from lms.djangoapps.course_blocks.utils import get_student_module_as_dict -from opaque_keys.edx.keys import CourseKey from openedx.core.djangolib.markup import HTML from openedx.core.lib.cache_utils import request_cached from openedx.features.course_experience import FIRST_PURCHASE_OFFER_BANNER_DISPLAY -from web_fragments.fragment import Fragment from xmodule.modulestore.django import modulestore diff --git a/openedx/features/course_experience/waffle.py b/openedx/features/course_experience/waffle.py index 8c96d36e07..cc50ed4968 100644 --- a/openedx/features/course_experience/waffle.py +++ b/openedx/features/course_experience/waffle.py @@ -1,6 +1,8 @@ """ Miscellaneous waffle switches that both LMS and Studio need to access """ +from __future__ import absolute_import + from openedx.core.djangoapps.waffle_utils import WaffleSwitchNamespace # Namespace diff --git a/openedx/features/course_search/urls.py b/openedx/features/course_search/urls.py index 0151991c24..0c9ae379e9 100644 --- a/openedx/features/course_search/urls.py +++ b/openedx/features/course_search/urls.py @@ -2,9 +2,11 @@ Defines URLs for course search. """ +from __future__ import absolute_import + from django.conf.urls import url -from views.course_search import CourseSearchView, CourseSearchFragmentView +from .views.course_search import CourseSearchFragmentView, CourseSearchView urlpatterns = [ url( diff --git a/openedx/features/course_search/views/course_search.py b/openedx/features/course_search/views/course_search.py index f0cbd57489..149267fb39 100644 --- a/openedx/features/course_search/views/course_search.py +++ b/openedx/features/course_search/views/course_search.py @@ -2,21 +2,24 @@ Views for the course search page. """ +from __future__ import absolute_import + +import six from django.contrib.auth.decorators import login_required from django.template.context_processors import csrf -from django.urls import reverse from django.template.loader import render_to_string +from django.urls import reverse from django.utils.decorators import method_decorator from django.views.decorators.cache import cache_control from django.views.decorators.csrf import ensure_csrf_cookie +from opaque_keys.edx.keys import CourseKey +from web_fragments.fragment import Fragment from courseware.courses import get_course_overview_with_access from lms.djangoapps.courseware.views.views import CourseTabView -from opaque_keys.edx.keys import CourseKey from openedx.core.djangoapps.plugin_api.views import EdxFragmentView from openedx.features.course_experience import default_course_url_name from util.views import ensure_valid_course_key -from web_fragments.fragment import Fragment class CourseSearchView(CourseTabView): @@ -34,7 +37,7 @@ class CourseSearchView(CourseTabView): return super(CourseSearchView, self).get(request, course_id, 'courseware', **kwargs) def render_to_fragment(self, request, course=None, tab=None, **kwargs): - course_id = unicode(course.id) + course_id = six.text_type(course.id) home_fragment_view = CourseSearchFragmentView() return home_fragment_view.render_to_fragment(request, course_id=course_id, **kwargs) @@ -50,7 +53,7 @@ class CourseSearchFragmentView(EdxFragmentView): course_key = CourseKey.from_string(course_id) course = get_course_overview_with_access(request.user, 'load', course_key, check_if_enrolled=True) course_url_name = default_course_url_name(course.id) - course_url = reverse(course_url_name, kwargs={'course_id': unicode(course.id)}) + course_url = reverse(course_url_name, kwargs={'course_id': six.text_type(course.id)}) # Render the course home fragment context = { diff --git a/openedx/features/coursetalk/migrations/0001_initial.py b/openedx/features/coursetalk/migrations/0001_initial.py index 0c0985f26c..b1d7139df0 100644 --- a/openedx/features/coursetalk/migrations/0001_initial.py +++ b/openedx/features/coursetalk/migrations/0001_initial.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from __future__ import absolute_import from django.db import migrations, models import django.db.models.deletion from django.conf import settings diff --git a/openedx/features/coursetalk/migrations/0002_auto_20160325_0631.py b/openedx/features/coursetalk/migrations/0002_auto_20160325_0631.py index 73f04f9065..e17f9c1283 100644 --- a/openedx/features/coursetalk/migrations/0002_auto_20160325_0631.py +++ b/openedx/features/coursetalk/migrations/0002_auto_20160325_0631.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from __future__ import absolute_import from django.db import migrations, models