ran modernize on openedx/features/course_search, course_experience, and coursetalk (#20423)
This commit is contained in:
committed by
Jeremy Bowman
parent
e298004f88
commit
4138445ad7
@@ -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')
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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 _
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from __future__ import absolute_import
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user