diff --git a/openedx/features/course_experience/__init__.py b/openedx/features/course_experience/__init__.py index 33202a2baea9cb13a72844e9bd85bcc705f2b8a8..386a3f41c3d802d0853c6dd7b84b8dfd5c2426f7 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 fe1f45f261aeff38f9721fec778e840852a33f56..23d1bb01355eb619a78ddfef49fa41adbc6986c0 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 e478a8b923a3236e86b323baca1375fad5644d26..9b25ada0b1039365d503cd78f27b306925340513 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 002d66b4afb9af360c5b64bff5c4b16f85b194d6..f764e918e8336c5e1072cda848f653a12051198b 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 f52a6479d13f5144f1e7fed379e97e26455ad4e0..01e636ba986c296c4abbc52a76d3f3db053168b4 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 8c96d36e077a374a0599e770e5857b3f547dc700..cc50ed49689a6d82d3a66b2a0fe1f06acff17878 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 0151991c249d0b83b7c1d2cb79163afcf535d3e6..0c9ae379e9aa34b9edf27f206851a13e1339ed48 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 f0cbd5748917edbc4e9dbfa328c397920f4e6ab9..149267fb394e6e8bd7a9edb69b2eeb5ba937f647 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 0c0985f26c6e39bb20c425fdc6a6206c168f6400..b1d7139df0475cc2b6703740209574658666d8a3 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 73f04f90657692031e0595169a23d24d50918721..e17f9c128377e50d38a3e078585e311320076f3b 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