refactor: pyupgrade second iteration (#27458)
This commit is contained in:
@@ -6,7 +6,7 @@ import ddt
|
||||
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from mock import patch
|
||||
from unittest.mock import patch
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
from common.djangoapps.student.models import CourseEnrollment
|
||||
|
||||
@@ -22,7 +22,7 @@ urlpatterns += [
|
||||
# URL for retrieving course deadlines info
|
||||
urlpatterns += [
|
||||
re_path(
|
||||
r'v1/course_deadlines_info/{}'.format(settings.COURSE_KEY_PATTERN),
|
||||
fr'v1/course_deadlines_info/{settings.COURSE_KEY_PATTERN}',
|
||||
CourseDeadlinesMobileView.as_view(),
|
||||
name='course-experience-course-deadlines-mobile'
|
||||
),
|
||||
|
||||
@@ -20,7 +20,7 @@ class HttpMethod(Enum):
|
||||
PUT = 'PUT'
|
||||
|
||||
|
||||
class CourseTool(object):
|
||||
class CourseTool:
|
||||
"""
|
||||
This is an optional base class for Course Tool plugins.
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class TestCourseDatesFragmentView(ModuleStoreTestCase):
|
||||
"""Tests for the course dates fragment view."""
|
||||
|
||||
def setUp(self):
|
||||
super(TestCourseDatesFragmentView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
with self.store.default_store(ModuleStoreEnum.Type.split):
|
||||
self.course = CourseFactory.create(
|
||||
org='edX',
|
||||
@@ -35,7 +35,7 @@ class TestCourseDatesFragmentView(ModuleStoreTestCase):
|
||||
self.dates_fragment_url = reverse(
|
||||
'openedx.course_experience.mobile_dates_fragment_view',
|
||||
kwargs={
|
||||
'course_id': six.text_type(self.course.id)
|
||||
'course_id': str(self.course.id)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
# coding=utf-8
|
||||
"""
|
||||
Tests for the course home page.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.http import QueryDict
|
||||
from django.urls import reverse
|
||||
@@ -92,7 +90,7 @@ def course_home_url(course):
|
||||
Arguments:
|
||||
course (CourseBlock): The course being tested.
|
||||
"""
|
||||
return course_home_url_from_string(six.text_type(course.id))
|
||||
return course_home_url_from_string(str(course.id))
|
||||
|
||||
|
||||
def course_home_url_from_string(course_key_string):
|
||||
@@ -369,7 +367,7 @@ class TestCourseHomePageAccess(CourseHomePageTestCase):
|
||||
"""
|
||||
url = course_home_url(self.course)
|
||||
response = self.client.get(url)
|
||||
self.assertContains(response, '/login?next={url}'.format(url=urlquote_plus(url)))
|
||||
self.assertContains(response, f'/login?next={urlquote_plus(url)}')
|
||||
|
||||
@mock.patch.dict(settings.FEATURES, {'DISABLE_START_DATES': False})
|
||||
def test_non_live_course(self):
|
||||
@@ -410,7 +408,7 @@ class TestCourseHomePageAccess(CourseHomePageTestCase):
|
||||
can_receive_discount_mock.return_value = applicability
|
||||
discount_percentage_mock.return_value = percentage
|
||||
user = self.create_user_for_course(self.course, CourseUserType.ENROLLED)
|
||||
now_time = datetime.now(tz=UTC).strftime(u"%Y-%m-%d %H:%M:%S%z")
|
||||
now_time = datetime.now(tz=UTC).strftime("%Y-%m-%d %H:%M:%S%z")
|
||||
ExperimentData.objects.create(
|
||||
user=user, experiment_id=REV1008_EXPERIMENT_ID, key=str(self.course.id), value=now_time
|
||||
)
|
||||
@@ -419,7 +417,7 @@ class TestCourseHomePageAccess(CourseHomePageTestCase):
|
||||
response = self.client.get(url)
|
||||
expiration_date = strftime_localized_html(get_discount_expiration_date(user, self.course), 'SHORT_DATE')
|
||||
upgrade_link = verified_upgrade_deadline_link(user=user, course=self.course)
|
||||
bannerText = u'''<div class="first-purchase-offer-banner" role="note">
|
||||
bannerText = '''<div class="first-purchase-offer-banner" role="note">
|
||||
<span class="first-purchase-offer-banner-bold"><b>
|
||||
Upgrade by {discount_expiration_date} and save {percentage}% [{strikeout_price}]</b></span>
|
||||
<br>Use code <b>EDXWELCOME</b> at checkout! <a id="welcome" href="{upgrade_link}">Upgrade Now</a>
|
||||
@@ -549,7 +547,7 @@ class TestCourseHomePageAccess(CourseHomePageTestCase):
|
||||
expiration_date = strftime_localized(course.start + timedelta(weeks=4) + timedelta(days=1), 'SHORT_DATE')
|
||||
expected_params = QueryDict(mutable=True)
|
||||
course_name = CourseOverview.get_from_id(course.id).display_name_with_default
|
||||
expected_params['access_response_error'] = u'Access to {run} expired on {expiration_date}'.format(
|
||||
expected_params['access_response_error'] = 'Access to {run} expired on {expiration_date}'.format(
|
||||
run=course_name,
|
||||
expiration_date=expiration_date
|
||||
)
|
||||
@@ -631,14 +629,14 @@ class TestCourseHomePageAccess(CourseHomePageTestCase):
|
||||
future_course = self.create_future_course()
|
||||
self.create_user_for_course(future_course, CourseUserType.ENROLLED)
|
||||
|
||||
fake_unicode_start_time = u"üñîçø∂é_ßtå®t_tîµé"
|
||||
fake_unicode_start_time = "üñîçø∂é_ßtå®t_tîµé"
|
||||
mock_strftime_localized.return_value = fake_unicode_start_time
|
||||
|
||||
url = course_home_url(future_course)
|
||||
response = self.client.get(url)
|
||||
expected_params = QueryDict(mutable=True)
|
||||
expected_params['notlive'] = fake_unicode_start_time
|
||||
expected_url = u'{url}?{params}'.format(
|
||||
expected_url = '{url}?{params}'.format(
|
||||
url=reverse('dashboard'),
|
||||
params=expected_params.urlencode()
|
||||
)
|
||||
@@ -857,7 +855,7 @@ class CourseHomeFragmentViewTests(ModuleStoreTestCase):
|
||||
CREATE_USER = False
|
||||
|
||||
def setUp(self):
|
||||
super(CourseHomeFragmentViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
CommerceConfiguration.objects.create(checkout_on_ecommerce_service=True)
|
||||
|
||||
end = now() + timedelta(days=30)
|
||||
@@ -896,7 +894,7 @@ class CourseHomeFragmentViewTests(ModuleStoreTestCase):
|
||||
self.assertContains(response, url)
|
||||
self.assertContains(
|
||||
response,
|
||||
u"Upgrade (<span class='price'>${price}</span>)".format(price=self.verified_mode.min_price),
|
||||
f"Upgrade (<span class='price'>${self.verified_mode.min_price}</span>)",
|
||||
)
|
||||
|
||||
def test_no_upgrade_message_if_logged_out(self):
|
||||
|
||||
@@ -5,9 +5,9 @@ Tests for the Course Outline view and supporting views.
|
||||
|
||||
import datetime
|
||||
import re
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import ddt
|
||||
import six
|
||||
from completion.waffle import ENABLE_COMPLETION_TRACKING_SWITCH
|
||||
from completion.models import BlockCompletion
|
||||
from completion.test_utils import CompletionWaffleTestMixin
|
||||
@@ -17,11 +17,9 @@ from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag, override_waffle_switch
|
||||
from milestones.tests.utils import MilestonesTestCaseMixin
|
||||
from mock import Mock, patch
|
||||
from opaque_keys.edx.keys import CourseKey, UsageKey
|
||||
from pyquery import PyQuery as pq
|
||||
from pytz import UTC
|
||||
from six import text_type
|
||||
from waffle.models import Switch
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
@@ -71,7 +69,7 @@ class TestCourseOutlinePage(SharedModuleStoreTestCase, MasqueradeMixin):
|
||||
|
||||
# setUpClassAndTestData() already calls setUpClass on SharedModuleStoreTestCase
|
||||
# pylint: disable=super-method-not-called
|
||||
with super(TestCourseOutlinePage, cls).setUpClassAndTestData():
|
||||
with super().setUpClassAndTestData():
|
||||
cls.courses = []
|
||||
course = CourseFactory.create(self_paced=True)
|
||||
with cls.store.bulk_operations(course.id):
|
||||
@@ -134,7 +132,7 @@ class TestCourseOutlinePage(SharedModuleStoreTestCase, MasqueradeMixin):
|
||||
"""
|
||||
Set up for the tests.
|
||||
"""
|
||||
super(TestCourseOutlinePage, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.client.login(username=self.user.username, password=TEST_PASSWORD)
|
||||
|
||||
@override_waffle_flag(RELATIVE_DATES_FLAG, active=True)
|
||||
@@ -160,7 +158,7 @@ class TestCourseOutlinePage(SharedModuleStoreTestCase, MasqueradeMixin):
|
||||
self.assertContains(response, sequential['display_name'])
|
||||
if sequential['graded']:
|
||||
print(sequential)
|
||||
self.assertContains(response, sequential['due'].strftime(u'%Y-%m-%d %H:%M:%S'))
|
||||
self.assertContains(response, sequential['due'].strftime('%Y-%m-%d %H:%M:%S'))
|
||||
self.assertContains(response, sequential['format'])
|
||||
assert sequential['children']
|
||||
|
||||
@@ -288,7 +286,7 @@ class TestCourseOutlinePageWithPrerequisites(SharedModuleStoreTestCase, Mileston
|
||||
cls.PREREQ_REQUIRED = '(Prerequisite required)'
|
||||
cls.UNLOCKED = 'Unlocked'
|
||||
|
||||
with super(TestCourseOutlinePageWithPrerequisites, cls).setUpClassAndTestData():
|
||||
with super().setUpClassAndTestData():
|
||||
cls.course, cls.course_blocks = cls.create_test_course()
|
||||
|
||||
@classmethod
|
||||
@@ -339,7 +337,7 @@ class TestCourseOutlinePageWithPrerequisites(SharedModuleStoreTestCase, Mileston
|
||||
"""
|
||||
Set up for the tests.
|
||||
"""
|
||||
super(TestCourseOutlinePageWithPrerequisites, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.client.login(username=self.user.username, password=TEST_PASSWORD)
|
||||
|
||||
def setup_gated_section(self, gated_block, gating_block):
|
||||
@@ -350,7 +348,7 @@ class TestCourseOutlinePageWithPrerequisites(SharedModuleStoreTestCase, Mileston
|
||||
gating_block: (The prerequisite) The block that must be completed to get access to the gated block
|
||||
"""
|
||||
|
||||
gating_api.add_prerequisite(self.course.id, six.text_type(gating_block.location))
|
||||
gating_api.add_prerequisite(self.course.id, str(gating_block.location))
|
||||
gating_api.set_required_content(self.course.id, gated_block.location, gating_block.location, 100)
|
||||
|
||||
def test_content_locked(self):
|
||||
@@ -437,7 +435,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
"""
|
||||
# setUpClassAndTestData() already calls setUpClass on SharedModuleStoreTestCase
|
||||
# pylint: disable=super-method-not-called
|
||||
with super(TestCourseOutlineResumeCourse, cls).setUpClassAndTestData():
|
||||
with super().setUpClassAndTestData():
|
||||
cls.course = cls.create_test_course()
|
||||
|
||||
@classmethod
|
||||
@@ -479,7 +477,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
"""
|
||||
Set up for the tests.
|
||||
"""
|
||||
super(TestCourseOutlineResumeCourse, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.client.login(username=self.user.username, password=TEST_PASSWORD)
|
||||
|
||||
def visit_sequential(self, course, chapter, sequential):
|
||||
@@ -489,7 +487,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
last_accessed_url = reverse(
|
||||
'courseware_section',
|
||||
kwargs={
|
||||
'course_id': text_type(course.id),
|
||||
'course_id': str(course.id),
|
||||
'chapter': chapter.url_name,
|
||||
'section': sequential.url_name,
|
||||
}
|
||||
@@ -503,7 +501,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
"""
|
||||
course_key = CourseKey.from_string(str(course.id))
|
||||
# Fake a visit to sequence2/vertical2
|
||||
block_key = UsageKey.from_string(six.text_type(sequential.location))
|
||||
block_key = UsageKey.from_string(str(sequential.location))
|
||||
if block_key.course_key.run is None:
|
||||
# Old mongo keys must be annotated with course run info before calling submit_completion:
|
||||
block_key = block_key.replace(course_key=course_key)
|
||||
@@ -564,7 +562,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
content = pq(response.content)
|
||||
|
||||
vertical = course.children[0].children[0].children[0]
|
||||
assert content('.action-resume-course').attr('href').endswith(('/vertical/' + vertical.url_name))
|
||||
assert content('.action-resume-course').attr('href').endswith('/vertical/' + vertical.url_name)
|
||||
|
||||
@override_settings(LMS_BASE='test_url:9999')
|
||||
def test_resume_course_with_completion_api(self):
|
||||
@@ -584,7 +582,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
|
||||
# Test for 'resume' link URL - should be vertical 1
|
||||
content = pq(response.content)
|
||||
assert content('.action-resume-course').attr('href').endswith(('/vertical/' + vertical1.url_name))
|
||||
assert content('.action-resume-course').attr('href').endswith('/vertical/' + vertical1.url_name)
|
||||
|
||||
self.complete_sequential(self.course, vertical2)
|
||||
# Test for 'resume' link
|
||||
@@ -592,7 +590,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
|
||||
# Test for 'resume' link URL - should be vertical 2
|
||||
content = pq(response.content)
|
||||
assert content('.action-resume-course').attr('href').endswith(('/vertical/' + vertical2.url_name))
|
||||
assert content('.action-resume-course').attr('href').endswith('/vertical/' + vertical2.url_name)
|
||||
|
||||
# visit sequential 1, make sure 'Resume Course' URL is robust against 'Last Visited'
|
||||
# (even though I visited seq1/vert1, 'Resume Course' still points to seq2/vert2)
|
||||
@@ -601,7 +599,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
# Test for 'resume' link URL - should be vertical 2 (last completed block, NOT last visited)
|
||||
response = self.visit_course_home(course, resume_count=1)
|
||||
content = pq(response.content)
|
||||
assert content('.action-resume-course').attr('href').endswith(('/vertical/' + vertical2.url_name))
|
||||
assert content('.action-resume-course').attr('href').endswith('/vertical/' + vertical2.url_name)
|
||||
|
||||
def test_resume_course_deleted_sequential(self):
|
||||
"""
|
||||
@@ -627,7 +625,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
response = self.visit_course_home(course, resume_count=1)
|
||||
|
||||
content = pq(response.content)
|
||||
assert content('.action-resume-course').attr('href').endswith(('/sequential/' + sequential2.url_name))
|
||||
assert content('.action-resume-course').attr('href').endswith('/sequential/' + sequential2.url_name)
|
||||
|
||||
def test_resume_course_deleted_sequentials(self):
|
||||
"""
|
||||
@@ -665,7 +663,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
response = self.visit_course_home(course, start_count=1, resume_count=0)
|
||||
content = pq(response.content)
|
||||
vertical = course.children[0].children[0].children[0]
|
||||
assert content('.action-resume-course').attr('href').endswith(('/vertical/' + vertical.url_name))
|
||||
assert content('.action-resume-course').attr('href').endswith('/vertical/' + vertical.url_name)
|
||||
|
||||
@override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, active=True)
|
||||
def test_course_outline_auto_open(self):
|
||||
@@ -687,10 +685,10 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
|
||||
chapter2 = course.children[1]
|
||||
|
||||
response_content = self.client.get(course_home_url(course)).content
|
||||
stripped_response = text_type(re.sub(b"\\s+", b"", response_content), "utf-8")
|
||||
stripped_response = str(re.sub(b"\\s+", b"", response_content), "utf-8")
|
||||
|
||||
assert get_sequential_button(text_type(chapter1.location), False) in stripped_response
|
||||
assert get_sequential_button(text_type(chapter2.location), True) in stripped_response
|
||||
assert get_sequential_button(str(chapter1.location), False) in stripped_response
|
||||
assert get_sequential_button(str(chapter2.location), True) in stripped_response
|
||||
|
||||
content = pq(response_content)
|
||||
button = content('#expand-collapse-outline-all-button')
|
||||
|
||||
@@ -3,8 +3,9 @@ Tests for course verification sock
|
||||
"""
|
||||
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
@@ -29,7 +30,7 @@ class TestCourseSockView(SharedModuleStoreTestCase):
|
||||
"""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestCourseSockView, cls).setUpClass()
|
||||
super().setUpClass()
|
||||
|
||||
# Create four courses
|
||||
cls.standard_course = CourseFactory.create()
|
||||
@@ -43,7 +44,7 @@ class TestCourseSockView(SharedModuleStoreTestCase):
|
||||
add_course_mode(cls.verified_course_already_enrolled, upgrade_deadline_expired=False)
|
||||
|
||||
def setUp(self):
|
||||
super(TestCourseSockView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.user = UserFactory.create()
|
||||
|
||||
# Enroll the user in the four courses
|
||||
|
||||
@@ -26,7 +26,7 @@ class MasqueradeTestBase(SharedModuleStoreTestCase, MasqueradeMixin):
|
||||
"""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(MasqueradeTestBase, cls).setUpClass()
|
||||
super().setUpClass()
|
||||
|
||||
# Create two courses
|
||||
cls.verified_course = CourseFactory.create()
|
||||
@@ -37,7 +37,7 @@ class MasqueradeTestBase(SharedModuleStoreTestCase, MasqueradeMixin):
|
||||
add_course_mode(cls.masters_course, mode_slug='masters', mode_display_name='Masters')
|
||||
|
||||
def setUp(self):
|
||||
super(MasqueradeTestBase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.course_staff = UserFactory.create()
|
||||
CourseStaffRole(self.verified_course.id).add_users(self.course_staff)
|
||||
CourseStaffRole(self.masters_course.id).add_users(self.course_staff)
|
||||
|
||||
@@ -88,13 +88,13 @@ def _get_legacy_courseware_url(
|
||||
# args provided by the redirect.
|
||||
# Rely on index to do all error handling and access control.
|
||||
if chapter is None:
|
||||
redirect_url = reverse('courseware', args=(six.text_type(course_key), ))
|
||||
redirect_url = reverse('courseware', args=(str(course_key), ))
|
||||
elif section is None:
|
||||
redirect_url = reverse('courseware_chapter', args=(six.text_type(course_key), chapter))
|
||||
redirect_url = reverse('courseware_chapter', args=(str(course_key), chapter))
|
||||
elif position is None:
|
||||
redirect_url = reverse(
|
||||
'courseware_section',
|
||||
args=(six.text_type(course_key), chapter, section)
|
||||
args=(str(course_key), chapter, section)
|
||||
)
|
||||
else:
|
||||
# Here we use the navigation_index from the position returned from
|
||||
@@ -102,9 +102,9 @@ def _get_legacy_courseware_url(
|
||||
# moment
|
||||
redirect_url = reverse(
|
||||
'courseware_position',
|
||||
args=(six.text_type(course_key), chapter, section, navigation_index(position))
|
||||
args=(str(course_key), chapter, section, navigation_index(position))
|
||||
)
|
||||
redirect_url += "?{}".format(urlencode({'activate_block_id': six.text_type(final_target_id)}))
|
||||
redirect_url += "?{}".format(urlencode({'activate_block_id': str(final_target_id)}))
|
||||
return redirect_url
|
||||
|
||||
|
||||
@@ -177,13 +177,13 @@ def make_learning_mfe_courseware_url(
|
||||
`course_key`, `sequence_key`, and `unit_key` can be either OpaqueKeys or
|
||||
strings. They're only ever used to concatenate a URL string.
|
||||
"""
|
||||
mfe_link = '{}/course/{}'.format(settings.LEARNING_MICROFRONTEND_URL, course_key)
|
||||
mfe_link = f'{settings.LEARNING_MICROFRONTEND_URL}/course/{course_key}'
|
||||
|
||||
if sequence_key:
|
||||
mfe_link += '/{}'.format(sequence_key)
|
||||
mfe_link += f'/{sequence_key}'
|
||||
|
||||
if unit_key:
|
||||
mfe_link += '/{}'.format(unit_key)
|
||||
mfe_link += f'/{unit_key}'
|
||||
|
||||
return mfe_link
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class CourseDatesFragmentMobileView(CourseDatesFragmentView):
|
||||
def get(self, request, *args, **kwargs):
|
||||
if not request.user.is_authenticated:
|
||||
raise Http404
|
||||
return super(CourseDatesFragmentMobileView, self).get(request, *args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
def css_dependencies(self):
|
||||
"""
|
||||
|
||||
@@ -52,7 +52,7 @@ from .course_sock import CourseSockFragmentView
|
||||
from .latest_update import LatestUpdateFragmentView
|
||||
from .welcome_message import WelcomeMessageFragmentView
|
||||
|
||||
EMPTY_HANDOUTS_HTML = u'<ol></ol>'
|
||||
EMPTY_HANDOUTS_HTML = '<ol></ol>'
|
||||
|
||||
|
||||
class CourseHomeView(CourseTabView):
|
||||
@@ -67,10 +67,10 @@ class CourseHomeView(CourseTabView):
|
||||
"""
|
||||
Displays the home page for the specified course.
|
||||
"""
|
||||
return super(CourseHomeView, self).get(request, course_id, 'courseware', **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
return super().get(request, course_id, 'courseware', **kwargs)
|
||||
|
||||
def render_to_fragment(self, request, course=None, tab=None, **kwargs): # lint-amnesty, pylint: disable=arguments-differ, unused-argument
|
||||
course_id = six.text_type(course.id)
|
||||
course_id = str(course.id)
|
||||
if course_home_mfe_outline_tab_is_active(course.id) and not request.user.is_staff:
|
||||
microfrontend_url = get_learning_mfe_home_url(course_key=course_id, view_name="home")
|
||||
raise Redirect(microfrontend_url)
|
||||
|
||||
@@ -114,17 +114,17 @@ def _register_course_home_messages(request, course, user_access, course_start_da
|
||||
allow_anonymous = check_public_access(course, [COURSE_VISIBILITY_PUBLIC])
|
||||
|
||||
if user_access['is_anonymous'] and not allow_anonymous:
|
||||
sign_in_or_register_text = (_(u'{sign_in_link} or {register_link} and then enroll in this course.')
|
||||
sign_in_or_register_text = (_('{sign_in_link} or {register_link} and then enroll in this course.')
|
||||
if not CourseMode.is_masters_only(course.id)
|
||||
else _(u'{sign_in_link} or {register_link}.'))
|
||||
else _('{sign_in_link} or {register_link}.'))
|
||||
CourseHomeMessages.register_info_message(
|
||||
request,
|
||||
Text(sign_in_or_register_text).format(
|
||||
sign_in_link=HTML(u'<a href="/login?next={current_url}">{sign_in_label}</a>').format(
|
||||
sign_in_link=HTML('<a href="/login?next={current_url}">{sign_in_label}</a>').format(
|
||||
sign_in_label=_('Sign in'),
|
||||
current_url=urlquote_plus(request.path),
|
||||
),
|
||||
register_link=HTML(u'<a href="/register?next={current_url}">{register_label}</a>').format(
|
||||
register_link=HTML('<a href="/register?next={current_url}">{register_label}</a>').format(
|
||||
register_label=_('register'),
|
||||
current_url=urlquote_plus(request.path),
|
||||
)
|
||||
@@ -134,7 +134,7 @@ def _register_course_home_messages(request, course, user_access, course_start_da
|
||||
if not user_access['is_anonymous'] and not user_access['is_staff'] and \
|
||||
not user_access['is_enrolled']:
|
||||
|
||||
title = Text(_(u'Welcome to {course_display_name}')).format(
|
||||
title = Text(_('Welcome to {course_display_name}')).format(
|
||||
course_display_name=course.display_name
|
||||
)
|
||||
|
||||
@@ -150,7 +150,7 @@ def _register_course_home_messages(request, course, user_access, course_start_da
|
||||
CourseHomeMessages.register_info_message(
|
||||
request,
|
||||
Text(_(
|
||||
u'{open_enroll_link}Enroll now{close_enroll_link} to access the full course.'
|
||||
'{open_enroll_link}Enroll now{close_enroll_link} to access the full course.'
|
||||
)).format(
|
||||
open_enroll_link=HTML('<button class="enroll-btn btn-link">'),
|
||||
close_enroll_link=HTML('</button>')
|
||||
@@ -171,7 +171,7 @@ def _register_course_goal_message(request, course):
|
||||
course_goal_options = get_course_goal_options()
|
||||
goal_choices_html = Text(_(
|
||||
'To start, set a course goal by selecting the option below that best describes '
|
||||
u'your learning plan. {goal_options_container}'
|
||||
'your learning plan. {goal_options_container}'
|
||||
)).format(
|
||||
goal_options_container=HTML('<div class="row goal-options-container">')
|
||||
)
|
||||
@@ -181,11 +181,11 @@ def _register_course_goal_message(request, course):
|
||||
'{initial_tag}{choice}{closing_tag}'
|
||||
).format(
|
||||
initial_tag=HTML(
|
||||
u'<div tabindex="0" aria-label="{aria_label_choice}" class="goal-option dismissible" '
|
||||
'<div tabindex="0" aria-label="{aria_label_choice}" class="goal-option dismissible" '
|
||||
'data-choice="{goal_key}">'
|
||||
).format(
|
||||
goal_key=GOAL_KEY_CHOICES.unsure,
|
||||
aria_label_choice=Text(_(u"Set goal to: {choice}")).format(
|
||||
aria_label_choice=Text(_("Set goal to: {choice}")).format(
|
||||
choice=course_goal_options[GOAL_KEY_CHOICES.unsure],
|
||||
),
|
||||
),
|
||||
@@ -204,11 +204,11 @@ def _register_course_goal_message(request, course):
|
||||
'{initial_tag}{goal_text}{closing_tag}'
|
||||
).format(
|
||||
initial_tag=HTML(
|
||||
u'<button tabindex="0" aria-label="{aria_label_choice}" class="goal-option btn-outline-primary" '
|
||||
'<button tabindex="0" aria-label="{aria_label_choice}" class="goal-option btn-outline-primary" '
|
||||
'data-choice="{goal_key}">'
|
||||
).format(
|
||||
goal_key=goal_key,
|
||||
aria_label_choice=Text(_(u"Set goal to: {goal_text}")).format(
|
||||
aria_label_choice=Text(_("Set goal to: {goal_text}")).format(
|
||||
goal_text=Text(_(goal_text)) # lint-amnesty, pylint: disable=translation-of-non-string
|
||||
)
|
||||
),
|
||||
@@ -222,7 +222,7 @@ def _register_course_goal_message(request, course):
|
||||
goal_choices_html=goal_choices_html,
|
||||
closing_tag=HTML('</div>')
|
||||
),
|
||||
title=Text(_(u'Welcome to {course_display_name}')).format(
|
||||
title=Text(_('Welcome to {course_display_name}')).format(
|
||||
course_display_name=course.display_name
|
||||
)
|
||||
)
|
||||
|
||||
@@ -29,10 +29,10 @@ class CourseUpdatesView(CourseTabView):
|
||||
"""
|
||||
Displays the home page for the specified course.
|
||||
"""
|
||||
return super(CourseUpdatesView, self).get(request, course_id, 'courseware', **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
return super().get(request, course_id, 'courseware', **kwargs)
|
||||
|
||||
def render_to_fragment(self, request, course=None, tab=None, **kwargs): # lint-amnesty, pylint: disable=arguments-differ, unused-argument
|
||||
course_id = six.text_type(course.id)
|
||||
course_id = str(course.id)
|
||||
updates_fragment_view = CourseUpdatesFragmentView()
|
||||
return updates_fragment_view.render_to_fragment(request, course_id=course_id, **kwargs)
|
||||
|
||||
@@ -49,7 +49,7 @@ class CourseUpdatesFragmentView(EdxFragmentView):
|
||||
course_key = CourseKey.from_string(course_id)
|
||||
course = get_course_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': six.text_type(course.id)})
|
||||
course_url = reverse(course_url_name, kwargs={'course_id': str(course.id)})
|
||||
|
||||
ordered_updates = get_ordered_updates(request, course)
|
||||
plain_html_updates = ''
|
||||
|
||||
@@ -36,7 +36,7 @@ class WelcomeMessageFragmentView(EdxFragmentView):
|
||||
return None
|
||||
|
||||
dismiss_url = reverse(
|
||||
'openedx.course_experience.dismiss_welcome_message', kwargs={'course_id': six.text_type(course_key)}
|
||||
'openedx.course_experience.dismiss_welcome_message', kwargs={'course_id': str(course_key)}
|
||||
)
|
||||
|
||||
context = {
|
||||
|
||||
@@ -6,7 +6,7 @@ Miscellaneous waffle switches that both LMS and Studio need to access
|
||||
from edx_toggles.toggles import LegacyWaffleSwitchNamespace
|
||||
|
||||
# Namespace
|
||||
WAFFLE_NAMESPACE = u'course_experience'
|
||||
WAFFLE_NAMESPACE = 'course_experience'
|
||||
|
||||
# Switches
|
||||
# .. toggle_name: course_experience.enable_about_sidebar_html
|
||||
@@ -16,7 +16,7 @@ WAFFLE_NAMESPACE = u'course_experience'
|
||||
# .. toggle_use_cases: open_edx
|
||||
# .. toggle_creation_date: 2018-01-26
|
||||
# TODO: Replace with WaffleSwitch(). See waffle() docstring.
|
||||
ENABLE_COURSE_ABOUT_SIDEBAR_HTML = u'enable_about_sidebar_html'
|
||||
ENABLE_COURSE_ABOUT_SIDEBAR_HTML = 'enable_about_sidebar_html'
|
||||
|
||||
|
||||
def waffle():
|
||||
@@ -29,4 +29,4 @@ def waffle():
|
||||
|
||||
ENABLE_COURSE_ABOUT_SIDEBAR_HTML = WaffleSwitch(f'{WAFFLE_NAMESPACE}.enable_about_sidebar_html')
|
||||
"""
|
||||
return LegacyWaffleSwitchNamespace(name=WAFFLE_NAMESPACE, log_prefix=u'Course Experience: ')
|
||||
return LegacyWaffleSwitchNamespace(name=WAFFLE_NAMESPACE, log_prefix='Course Experience: ')
|
||||
|
||||
Reference in New Issue
Block a user