From 3d1f3cea645d545ee0b047816516c0d9d1f274d5 Mon Sep 17 00:00:00 2001 From: usamasadiq Date: Mon, 15 Feb 2021 14:29:50 +0500 Subject: [PATCH] Ran pyupgrade on lms/djangoapps/course_blocks Ran pyupgrade on lms/djangoapps/course_goals Ran pyugprade on lms/djangoapps/course_home_api --- .../transformers/hidden_content.py | 2 +- .../transformers/library_content.py | 19 +++++++-------- .../course_blocks/transformers/split_test.py | 4 +--- .../course_blocks/transformers/start_date.py | 1 + .../transformers/tests/helpers.py | 20 +++++++--------- .../transformers/tests/test_hidden_content.py | 5 ++-- .../tests/test_library_content.py | 13 +++++----- .../tests/test_load_override_data.py | 6 ++--- .../transformers/tests/test_split_test.py | 4 ++-- .../transformers/tests/test_start_date.py | 9 ++++--- .../tests/test_user_partitions.py | 22 ++++++++--------- .../transformers/user_partitions.py | 4 +--- lms/djangoapps/course_blocks/usage_info.py | 2 +- lms/djangoapps/course_goals/api.py | 3 +-- lms/djangoapps/course_goals/handlers.py | 4 +--- .../course_goals/migrations/0001_initial.py | 8 ++----- .../migrations/0002_auto_20171010_1129.py | 6 +---- lms/djangoapps/course_goals/models.py | 10 ++++---- lms/djangoapps/course_goals/tests/test_api.py | 7 +++--- lms/djangoapps/course_goals/views.py | 8 +++---- .../course_metadata/v1/tests/test_views.py | 3 +-- .../course_metadata/v1/views.py | 5 ++-- .../course_home_api/dates/v1/serializers.py | 2 +- .../dates/v1/tests/test_views.py | 4 ++-- .../course_home_api/dates/v1/views.py | 15 ++++++------ .../outline/v1/tests/test_views.py | 12 ++++++---- .../course_home_api/outline/v1/views.py | 24 ++++++++++++------- .../progress/v1/serializers.py | 1 + .../progress/v1/tests/test_views.py | 6 ++--- .../course_home_api/progress/v1/views.py | 13 ++++------ lms/djangoapps/course_home_api/tests/utils.py | 7 ++++-- lms/djangoapps/course_home_api/toggles.py | 1 + lms/djangoapps/course_home_api/urls.py | 10 ++++---- lms/djangoapps/course_home_api/utils.py | 4 ++-- 34 files changed, 127 insertions(+), 137 deletions(-) diff --git a/lms/djangoapps/course_blocks/transformers/hidden_content.py b/lms/djangoapps/course_blocks/transformers/hidden_content.py index e877832e59..7756de0b52 100644 --- a/lms/djangoapps/course_blocks/transformers/hidden_content.py +++ b/lms/djangoapps/course_blocks/transformers/hidden_content.py @@ -88,7 +88,7 @@ class HiddenContentTransformer(FilteringTransformerMixin, BlockStructureTransfor func_merge_ancestors=min, ) - block_structure.request_xblock_fields(u'self_paced', u'end') + block_structure.request_xblock_fields('self_paced', 'end') def transform_block_filters(self, usage_info, block_structure): # Users with staff access bypass the Visibility check. diff --git a/lms/djangoapps/course_blocks/transformers/library_content.py b/lms/djangoapps/course_blocks/transformers/library_content.py index da56dc81b9..e00d83c74f 100644 --- a/lms/djangoapps/course_blocks/transformers/library_content.py +++ b/lms/djangoapps/course_blocks/transformers/library_content.py @@ -6,15 +6,14 @@ Content Library Transformer. import json import logging -import six from eventtracking import tracker +from common.djangoapps.track import contexts from lms.djangoapps.courseware.models import StudentModule from openedx.core.djangoapps.content.block_structure.transformer import ( BlockStructureTransformer, FilteringTransformerMixin ) -from common.djangoapps.track import contexts from xmodule.library_content_module import LibraryContentBlock from xmodule.modulestore.django import modulestore @@ -58,9 +57,9 @@ class ContentLibraryTransformer(FilteringTransformerMixin, BlockStructureTransfo """ Basic information about the given block """ orig_key, orig_version = store.get_block_original_usage(usage_key) return { - "usage_key": six.text_type(usage_key), - "original_usage_key": six.text_type(orig_key) if orig_key else None, - "original_usage_version": six.text_type(orig_version) if orig_version else None, + "usage_key": str(usage_key), + "original_usage_key": str(orig_key) if orig_key else None, + "original_usage_version": str(orig_version) if orig_version else None, } # For each block check if block is library_content. @@ -162,7 +161,7 @@ class ContentLibraryTransformer(FilteringTransformerMixin, BlockStructureTransfo Helper function to publish an event for analytics purposes """ event_data = { - "location": six.text_type(location), + "location": str(location), "previous_count": previous_count, "result": result, "max_count": max_count, @@ -171,7 +170,7 @@ class ContentLibraryTransformer(FilteringTransformerMixin, BlockStructureTransfo context = contexts.course_context_from_course_id(location.course_key) if user_id: context['user_id'] = user_id - full_event_name = "edx.librarycontentblock.content.{}".format(event_name) + full_event_name = f"edx.librarycontentblock.content.{event_name}" with tracker.get_tracker().context(full_event_name, context): tracker.emit(full_event_name, event_data) @@ -225,8 +224,8 @@ class ContentLibraryOrderTransformer(BlockStructureTransformer): if library_children: state_dict = get_student_module_as_dict(usage_info.user, usage_info.course_key, block_key) - current_children_blocks = set(block.block_id for block in library_children) - current_selected_blocks = set(item[1] for item in state_dict['selected']) + current_children_blocks = {block.block_id for block in library_children} + current_selected_blocks = {item[1] for item in state_dict['selected']} # As the selections should have already been made by the ContentLibraryTransformer, # the current children of the library_content block should be the same as the stored @@ -235,7 +234,7 @@ class ContentLibraryOrderTransformer(BlockStructureTransformer): # transform the order in that case. if current_children_blocks != current_selected_blocks: logger.debug( - u'Mismatch between the children of %s in the stored state and the actual children for user %s. ' + 'Mismatch between the children of %s in the stored state and the actual children for user %s. ' 'Continuing without order transformation.', str(block_key), usage_info.user.username diff --git a/lms/djangoapps/course_blocks/transformers/split_test.py b/lms/djangoapps/course_blocks/transformers/split_test.py index 6e3640e693..80b8fba369 100644 --- a/lms/djangoapps/course_blocks/transformers/split_test.py +++ b/lms/djangoapps/course_blocks/transformers/split_test.py @@ -3,8 +3,6 @@ Split Test Block Transformer """ -import six - from openedx.core.djangoapps.content.block_structure.transformer import ( BlockStructureTransformer, FilteringTransformerMixin @@ -65,7 +63,7 @@ class SplitTestTransformer(FilteringTransformerMixin, BlockStructureTransformer) # Create dict of child location to group_id, using the # group_id_to_child field on the split_test module. child_to_group = { - xblock.group_id_to_child.get(six.text_type(group.id), None): group.id + xblock.group_id_to_child.get(str(group.id), None): group.id for group in partition_for_this_block.groups } diff --git a/lms/djangoapps/course_blocks/transformers/start_date.py b/lms/djangoapps/course_blocks/transformers/start_date.py index 5edde343b7..f6086e6f82 100644 --- a/lms/djangoapps/course_blocks/transformers/start_date.py +++ b/lms/djangoapps/course_blocks/transformers/start_date.py @@ -3,6 +3,7 @@ Start Date Transformer implementation. """ from datetime import datetime + from pytz import UTC from lms.djangoapps.courseware.access_utils import check_start_date diff --git a/lms/djangoapps/course_blocks/transformers/tests/helpers.py b/lms/djangoapps/course_blocks/transformers/tests/helpers.py index 08d771290d..2562a367f3 100644 --- a/lms/djangoapps/course_blocks/transformers/tests/helpers.py +++ b/lms/djangoapps/course_blocks/transformers/tests/helpers.py @@ -3,15 +3,13 @@ Test helpers for testing course block transformers. """ -import six -from six.moves import range -from mock import patch +from unittest.mock import patch from common.djangoapps.course_modes.models import CourseMode +from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from lms.djangoapps.courseware.access import has_access from openedx.core.djangoapps.content.block_structure.tests.helpers import clear_registered_transformers_cache from openedx.core.djangoapps.content.block_structure.transformers import BlockStructureTransformers -from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase @@ -20,13 +18,13 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from ...api import get_course_blocks -class TransformerRegistryTestMixin(object): +class TransformerRegistryTestMixin: """ Mixin that overrides the TransformerRegistry so that it returns TRANSFORMER_CLASS_TO_TEST as a registered transformer. """ def setUp(self): - super(TransformerRegistryTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + super().setUp() self.patcher = patch( 'openedx.core.djangoapps.content.block_structure.transformer_registry.' 'TransformerRegistry.get_registered_transformers' @@ -48,7 +46,7 @@ class CourseStructureTestCase(TransformerRegistryTestMixin, ModuleStoreTestCase) """ Create users. """ - super(CourseStructureTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + super().setUp() # Set up users. self.password = 'test' self.user = UserFactory.create(password=self.password) @@ -60,7 +58,7 @@ class CourseStructureTestCase(TransformerRegistryTestMixin, ModuleStoreTestCase) course structures for the given block type and block reference string. """ - return '{}_{}'.format(block_type, block_ref) + return f'{block_type}_{block_ref}' def build_xblock(self, block_hierarchy, block_map, parent): """ @@ -77,7 +75,7 @@ class CourseStructureTestCase(TransformerRegistryTestMixin, ModuleStoreTestCase) block_type = block_hierarchy['#type'] block_ref = block_hierarchy['#ref'] factory = (CourseFactory if block_type == 'course' else ItemFactory) - kwargs = {key: value for key, value in six.iteritems(block_hierarchy) if key[0] != '#'} + kwargs = {key: value for key, value in block_hierarchy.items() if key[0] != '#'} if block_type != 'course': kwargs['category'] = block_type @@ -199,7 +197,7 @@ class CourseStructureTestCase(TransformerRegistryTestMixin, ModuleStoreTestCase) Returns: set[UsageKey] """ xblocks = (blocks[ref] for ref in refs) - return set([xblock.location for xblock in xblocks]) # lint-amnesty, pylint: disable=consider-using-set-comprehension + return {xblock.location for xblock in xblocks} # lint-amnesty, pylint: disable=consider-using-set-comprehension class BlockParentsMapTestCase(TransformerRegistryTestMixin, ModuleStoreTestCase): @@ -221,7 +219,7 @@ class BlockParentsMapTestCase(TransformerRegistryTestMixin, ModuleStoreTestCase) parents_map = [[], [0], [0], [1], [1], [2], [2, 4]] def setUp(self): - super(BlockParentsMapTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + super().setUp() # create the course self.course = CourseFactory.create() diff --git a/lms/djangoapps/course_blocks/transformers/tests/test_hidden_content.py b/lms/djangoapps/course_blocks/transformers/tests/test_hidden_content.py index b1d3f1d5f3..4a041f7b6d 100644 --- a/lms/djangoapps/course_blocks/transformers/tests/test_hidden_content.py +++ b/lms/djangoapps/course_blocks/transformers/tests/test_hidden_content.py @@ -6,7 +6,6 @@ Tests for HiddenContentTransformer. from datetime import timedelta import ddt -import six from django.utils.timezone import now from ..hidden_content import HiddenContentTransformer @@ -21,7 +20,7 @@ class HiddenContentTransformerTestCase(BlockParentsMapTestCase): TRANSFORMER_CLASS_TO_TEST = HiddenContentTransformer ALL_BLOCKS = {0, 1, 2, 3, 4, 5, 6} - class DueDateType(object): + class DueDateType: """ Use constant enum types for deterministic ddt test method names (rather than dynamically generated timestamps) """ @@ -71,7 +70,7 @@ class HiddenContentTransformerTestCase(BlockParentsMapTestCase): hide_due_values, expected_visible_blocks, ): - for idx, due_date_type in six.iteritems(hide_due_values): + for idx, due_date_type in hide_due_values.items(): block = self.get_block(idx) block.due = self.DueDateType.due(due_date_type) block.hide_after_due = True diff --git a/lms/djangoapps/course_blocks/transformers/tests/test_library_content.py b/lms/djangoapps/course_blocks/transformers/tests/test_library_content.py index 5cdabcac9b..8612f466a8 100644 --- a/lms/djangoapps/course_blocks/transformers/tests/test_library_content.py +++ b/lms/djangoapps/course_blocks/transformers/tests/test_library_content.py @@ -3,19 +3,18 @@ Tests for ContentLibraryTransformer. """ -from six.moves import range -import mock +from unittest import mock +from common.djangoapps.student.tests.factories import CourseEnrollmentFactory from openedx.core.djangoapps.content.block_structure.api import clear_course_from_cache from openedx.core.djangoapps.content.block_structure.transformers import BlockStructureTransformers -from common.djangoapps.student.tests.factories import CourseEnrollmentFactory from ...api import get_course_blocks -from ..library_content import ContentLibraryTransformer, ContentLibraryOrderTransformer +from ..library_content import ContentLibraryOrderTransformer, ContentLibraryTransformer from .helpers import CourseStructureTestCase -class MockedModule(object): +class MockedModule: """ Object with mocked selected modules for user. """ @@ -36,7 +35,7 @@ class ContentLibraryTransformerTestCase(CourseStructureTestCase): """ Setup course structure and create user for content library transformer test. """ - super(ContentLibraryTransformerTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + super().setUp() # Build course. self.course_hierarchy = self.get_course_hierarchy() @@ -168,7 +167,7 @@ class ContentLibraryOrderTransformerTestCase(CourseStructureTestCase): """ Setup course structure and create user for content library order transformer test. """ - super(ContentLibraryOrderTransformerTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + super().setUp() self.course_hierarchy = self.get_course_hierarchy() self.blocks = self.build_course(self.course_hierarchy) self.course = self.blocks['course'] diff --git a/lms/djangoapps/course_blocks/transformers/tests/test_load_override_data.py b/lms/djangoapps/course_blocks/transformers/tests/test_load_override_data.py index 5ecce086ad..97f232cabc 100644 --- a/lms/djangoapps/course_blocks/transformers/tests/test_load_override_data.py +++ b/lms/djangoapps/course_blocks/transformers/tests/test_load_override_data.py @@ -8,10 +8,10 @@ import datetime import ddt import pytz +from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from lms.djangoapps.course_blocks.transformers.load_override_data import REQUESTED_FIELDS, OverrideDataTransformer from lms.djangoapps.courseware.student_field_overrides import get_override_for_user, override_field_for_user from openedx.core.djangoapps.content.block_structure.factory import BlockStructureFactory -from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import ToyCourseFactory @@ -35,12 +35,12 @@ class TestOverrideDataTransformer(ModuleStoreTestCase): @classmethod def setUpClass(cls): - super(TestOverrideDataTransformer, cls).setUpClass() + super().setUpClass() cls.learner = UserFactory.create() cls.learner2 = UserFactory.create() def setUp(self): - super(TestOverrideDataTransformer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + super().setUp() self.course_key = ToyCourseFactory.create().id self.course_usage_key = self.store.make_course_usage_key(self.course_key) self.block_structure = BlockStructureFactory.create_from_modulestore(self.course_usage_key, self.store) diff --git a/lms/djangoapps/course_blocks/transformers/tests/test_split_test.py b/lms/djangoapps/course_blocks/transformers/tests/test_split_test.py index eec874be97..35bcfcc5bd 100644 --- a/lms/djangoapps/course_blocks/transformers/tests/test_split_test.py +++ b/lms/djangoapps/course_blocks/transformers/tests/test_split_test.py @@ -6,8 +6,8 @@ Tests for SplitTestTransformer. import ddt import openedx.core.djangoapps.user_api.course_tag.api as course_tag_api -from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme from common.djangoapps.student.tests.factories import CourseEnrollmentFactory +from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme from xmodule.modulestore.tests.factories import check_mongo_calls from xmodule.partitions.partitions import Group, UserPartition from xmodule.partitions.partitions_service import get_user_partition_groups @@ -29,7 +29,7 @@ class SplitTestTransformerTestCase(CourseStructureTestCase): """ Setup course structure and create user for split test transformer test. """ - super(SplitTestTransformerTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + super().setUp() # Set up user partitions and groups. self.groups = [Group(0, 'Group 0'), Group(1, 'Group 1'), Group(2, 'Group 2')] diff --git a/lms/djangoapps/course_blocks/transformers/tests/test_start_date.py b/lms/djangoapps/course_blocks/transformers/tests/test_start_date.py index 706d656c5f..232e362894 100644 --- a/lms/djangoapps/course_blocks/transformers/tests/test_start_date.py +++ b/lms/djangoapps/course_blocks/transformers/tests/test_start_date.py @@ -4,11 +4,10 @@ Tests for StartDateTransformer. from datetime import timedelta +from unittest.mock import patch import ddt -import six from django.utils.timezone import now -from mock import patch from lms.djangoapps.courseware.tests.factories import BetaTesterFactory @@ -25,7 +24,7 @@ class StartDateTransformerTestCase(BlockParentsMapTestCase): BETA_USER = 2 TRANSFORMER_CLASS_TO_TEST = StartDateTransformer - class StartDateType(object): + class StartDateType: """ Use constant enum types for deterministic ddt test method names (rather than dynamically generated timestamps) """ @@ -50,7 +49,7 @@ class StartDateTransformerTestCase(BlockParentsMapTestCase): return DEFAULT_START_DATE def setUp(self): - super(StartDateTransformerTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + super().setUp() self.beta_user = BetaTesterFactory(course_key=self.course.id, username='beta_tester', password=self.password) course = self.get_block(0) course.days_early_for_beta = 33 @@ -110,7 +109,7 @@ class StartDateTransformerTestCase(BlockParentsMapTestCase): expected_student_visible_blocks, blocks_with_differing_student_access ): - for idx, start_date_type in six.iteritems(start_date_type_values): + for idx, start_date_type in start_date_type_values.items(): block = self.get_block(idx) block.start = self.StartDateType.start(start_date_type) update_block(block) diff --git a/lms/djangoapps/course_blocks/transformers/tests/test_user_partitions.py b/lms/djangoapps/course_blocks/transformers/tests/test_user_partitions.py index 35147f55a8..47f7e7597e 100644 --- a/lms/djangoapps/course_blocks/transformers/tests/test_user_partitions.py +++ b/lms/djangoapps/course_blocks/transformers/tests/test_user_partitions.py @@ -7,20 +7,18 @@ Tests for UserPartitionTransformer. import string from collections import namedtuple from datetime import datetime +from unittest.mock import patch import ddt -import six -from six.moves import range -from mock import patch from common.djangoapps.course_modes.tests.factories import CourseModeFactory +from common.djangoapps.student.tests.factories import CourseEnrollmentFactory from openedx.core.djangoapps.course_groups.cohorts import add_user_to_cohort from openedx.core.djangoapps.course_groups.partition_scheme import CohortPartitionScheme from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory, config_course_cohorts from openedx.core.djangoapps.course_groups.views import link_cohort_to_partition_group from openedx.features.content_type_gating.models import ContentTypeGatingConfig from openedx.features.content_type_gating.partitions import create_content_gating_partition -from common.djangoapps.student.tests.factories import CourseEnrollmentFactory from xmodule.modulestore.tests.factories import CourseFactory from xmodule.partitions.partitions import Group, UserPartition @@ -29,7 +27,7 @@ from ..user_partitions import UserPartitionTransformer, _MergedGroupAccess from .helpers import CourseStructureTestCase, update_block -class UserPartitionTestMixin(object): +class UserPartitionTestMixin: """ Helper Mixin for testing user partitions. """ @@ -42,15 +40,15 @@ class UserPartitionTestMixin(object): # Set up groups self.groups = [] for group_num in range(1, num_groups + 1): - self.groups.append(Group(group_num, 'Group ' + six.text_type(group_num))) + self.groups.append(Group(group_num, 'Group ' + str(group_num))) # Set up user partitions self.user_partitions = [] for user_partition_num in range(1, num_user_partitions + 1): user_partition = UserPartition( id=user_partition_num, - name='Partition ' + six.text_type(user_partition_num), - description='This is partition ' + six.text_type(user_partition_num), + name='Partition ' + str(user_partition_num), + description='This is partition ' + str(user_partition_num), groups=self.groups, scheme=CohortPartitionScheme, active=active, @@ -243,7 +241,7 @@ class UserPartitionTransformerTestCase(UserPartitionTestMixin, CourseStructureTe return_value=partition ), patch( 'lms.djangoapps.course_blocks.transformers.user_partitions._MergedGroupAccess.get_allowed_groups', - return_value={51: set([])} + return_value={51: set()} ): trans_block_structure = get_course_blocks( self.user, @@ -252,7 +250,7 @@ class UserPartitionTransformerTestCase(UserPartitionTestMixin, CourseStructureTe ) xblocks_denial_reason = [trans_block_structure.get_xblock_field(b, 'authorization_denial_reason') for b in trans_block_structure.get_block_keys()] - self.assertSetEqual(set(xblocks_denial_reason), set([u'Feature-based Enrollments'])) + self.assertSetEqual(set(xblocks_denial_reason), {'Feature-based Enrollments'}) def test_transform_on_inactive_partition(self): """ @@ -287,7 +285,7 @@ class MergedGroupAccessTestData(UserPartitionTestMixin, CourseStructureTestCase) Setup course structure and create user for user partition transformer test. """ - super(MergedGroupAccessTestData, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + super().setUp() # Set up multiple user partitions and groups. self.setup_groups_partitions(num_user_partitions=3) @@ -472,7 +470,7 @@ class MergedGroupAccessTestData(UserPartitionTestMixin, CourseStructureTestCase) merged_group_access = _MergedGroupAccess(self.user_partitions, block, merged_parents_list) # convert group_id to groups in user_partition_groups parameter - for partition_id, group_id in six.iteritems(user_partition_groups): + for partition_id, group_id in user_partition_groups.items(): user_partition_groups[partition_id] = self.groups[group_id - 1] assert merged_group_access.check_group_access(user_partition_groups) == expected_access diff --git a/lms/djangoapps/course_blocks/transformers/user_partitions.py b/lms/djangoapps/course_blocks/transformers/user_partitions.py index 5c09e6bbc5..d8baeaaf0e 100644 --- a/lms/djangoapps/course_blocks/transformers/user_partitions.py +++ b/lms/djangoapps/course_blocks/transformers/user_partitions.py @@ -3,8 +3,6 @@ User Partitions Transformer """ -import six # lint-amnesty, pylint: disable=unused-import - from lms.djangoapps.courseware.access import has_access from openedx.core.djangoapps.content.block_structure.transformer import ( # lint-amnesty, pylint: disable=unused-import BlockStructureTransformer, @@ -131,7 +129,7 @@ class UserPartitionTransformer(BlockStructureTransformer): ) -class _MergedGroupAccess(object): +class _MergedGroupAccess: """ A class object to represent the computed access value for a block, merged from the inherited values from its ancestors. diff --git a/lms/djangoapps/course_blocks/usage_info.py b/lms/djangoapps/course_blocks/usage_info.py index 7e9e678ce3..459d38bad4 100644 --- a/lms/djangoapps/course_blocks/usage_info.py +++ b/lms/djangoapps/course_blocks/usage_info.py @@ -7,7 +7,7 @@ Transformers. from lms.djangoapps.courseware.access import _has_access_to_course -class CourseUsageInfo(object): +class CourseUsageInfo: ''' A class object that encapsulates the course and user context to be used as currency across block structure transformers, by passing diff --git a/lms/djangoapps/course_goals/api.py b/lms/djangoapps/course_goals/api.py index 05bb49580b..07ce8f5161 100644 --- a/lms/djangoapps/course_goals/api.py +++ b/lms/djangoapps/course_goals/api.py @@ -6,7 +6,6 @@ Course Goals Python API from django.conf import settings from opaque_keys.edx.keys import CourseKey from rest_framework.reverse import reverse -from six import text_type from common.djangoapps.course_modes.models import CourseMode from openedx.features.course_experience import ENABLE_COURSE_GOALS @@ -25,7 +24,7 @@ def add_course_goal(user, course_id, goal_key): goal_key (string): The goal key for the new goal. """ - course_key = CourseKey.from_string(text_type(course_id)) + course_key = CourseKey.from_string(str(course_id)) current_goal = get_course_goal(user, course_key) if current_goal: # If a course goal already exists, simply update it. diff --git a/lms/djangoapps/course_goals/handlers.py b/lms/djangoapps/course_goals/handlers.py index 607c0b77fb..de5d64f609 100644 --- a/lms/djangoapps/course_goals/handlers.py +++ b/lms/djangoapps/course_goals/handlers.py @@ -3,11 +3,9 @@ Signal handlers for course goals. """ -import six from django.db import models from django.dispatch import receiver -import six # lint-amnesty, pylint: disable=reimported from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.student.models import CourseEnrollment @@ -22,7 +20,7 @@ def update_course_goal_on_enroll_change(sender, instance, **kwargs): # pylint: 1) Set the course goal to 'certify' when the user enrolls as a verified user. 2) Remove the course goal when the user's enrollment is no longer active. """ - course_id = six.text_type(instance.course_id) + course_id = str(instance.course_id) if not instance.is_active: remove_course_goal(instance.user, course_id) elif instance.mode == CourseMode.VERIFIED: diff --git a/lms/djangoapps/course_goals/migrations/0001_initial.py b/lms/djangoapps/course_goals/migrations/0001_initial.py index 60606da839..1dd8905d01 100644 --- a/lms/djangoapps/course_goals/migrations/0001_initial.py +++ b/lms/djangoapps/course_goals/migrations/0001_initial.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - - - from django.db import migrations, models from django.conf import settings from opaque_keys.edx.django.models import CourseKeyField @@ -19,12 +15,12 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('course_key', CourseKeyField(max_length=255, db_index=True)), - ('goal_key', models.CharField(default=u'unsure', max_length=100, choices=[(u'certify', 'Earn a certificate.'), (u'complete', 'Complete the course.'), (u'explore', 'Explore the course.'), (u'unsure', 'Not sure yet.')])), + ('goal_key', models.CharField(default='unsure', max_length=100, choices=[('certify', 'Earn a certificate.'), ('complete', 'Complete the course.'), ('explore', 'Explore the course.'), ('unsure', 'Not sure yet.')])), ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], ), migrations.AlterUniqueTogether( name='coursegoal', - unique_together=set([('user', 'course_key')]), + unique_together={('user', 'course_key')}, ), ] diff --git a/lms/djangoapps/course_goals/migrations/0002_auto_20171010_1129.py b/lms/djangoapps/course_goals/migrations/0002_auto_20171010_1129.py index 37ad1dbca7..0121aaafec 100644 --- a/lms/djangoapps/course_goals/migrations/0002_auto_20171010_1129.py +++ b/lms/djangoapps/course_goals/migrations/0002_auto_20171010_1129.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - - - from django.db import migrations, models @@ -15,6 +11,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='coursegoal', name='goal_key', - field=models.CharField(default=u'unsure', max_length=100, choices=[(u'certify', 'Earn a certificate'), (u'complete', 'Complete the course'), (u'explore', 'Explore the course'), (u'unsure', 'Not sure yet')]), + field=models.CharField(default='unsure', max_length=100, choices=[('certify', 'Earn a certificate'), ('complete', 'Complete the course'), ('explore', 'Explore the course'), ('unsure', 'Not sure yet')]), ), ] diff --git a/lms/djangoapps/course_goals/models.py b/lms/djangoapps/course_goals/models.py index bdcf1681cb..414d6ee98e 100644 --- a/lms/djangoapps/course_goals/models.py +++ b/lms/djangoapps/course_goals/models.py @@ -12,10 +12,10 @@ from opaque_keys.edx.django.models import CourseKeyField # Each goal is represented by a goal key and a string description. GOAL_KEY_CHOICES = Choices( - (u'certify', _('Earn a certificate')), - (u'complete', _('Complete the course')), - (u'explore', _('Explore the course')), - (u'unsure', _('Not sure yet')), + ('certify', _('Earn a certificate')), + ('complete', _('Complete the course')), + ('explore', _('Explore the course')), + ('unsure', _('Not sure yet')), ) @@ -26,7 +26,7 @@ class CourseGoal(models.Model): .. no_pii: """ - class Meta(object): + class Meta: app_label = "course_goals" unique_together = ("user", "course_key") diff --git a/lms/djangoapps/course_goals/tests/test_api.py b/lms/djangoapps/course_goals/tests/test_api.py index d481c99341..cf25849680 100644 --- a/lms/djangoapps/course_goals/tests/test_api.py +++ b/lms/djangoapps/course_goals/tests/test_api.py @@ -3,15 +3,16 @@ Unit tests for course_goals.api methods. """ -import mock +from unittest import mock + from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.test.utils import override_settings from django.urls import reverse from rest_framework.test import APIClient -from lms.djangoapps.course_goals.models import CourseGoal from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.track.tests import EventTrackingTestCase +from lms.djangoapps.course_goals.models import CourseGoal from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory @@ -27,7 +28,7 @@ class TestCourseGoalsAPI(EventTrackingTestCase, SharedModuleStoreTestCase): def setUp(self): # Create a course with a verified track - super(TestCourseGoalsAPI, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + super().setUp() self.course = CourseFactory.create(emit_signals=True) self.user = User.objects.create_user('john', 'lennon@thebeatles.com', 'password') diff --git a/lms/djangoapps/course_goals/views.py b/lms/djangoapps/course_goals/views.py index 379b0e64b1..81ef5f0680 100644 --- a/lms/djangoapps/course_goals/views.py +++ b/lms/djangoapps/course_goals/views.py @@ -14,8 +14,8 @@ from rest_framework import permissions, serializers, status, viewsets from rest_framework.authentication import SessionAuthentication from rest_framework.response import Response -from openedx.core.lib.api.permissions import IsStaffOrOwner from common.djangoapps.track import segment +from openedx.core.lib.api.permissions import IsStaffOrOwner from .api import get_course_goal_options from .models import GOAL_KEY_CHOICES, CourseGoal @@ -65,14 +65,14 @@ class CourseGoalViewSet(viewsets.ModelViewSet): goal_key = post_data.data.get('goal_key') if not goal_key: return Response( - u'Please provide a valid goal key from following options. (options= {goal_options}).'.format( + 'Please provide a valid goal key from following options. (options= {goal_options}).'.format( goal_options=goal_options, ), status=status.HTTP_400_BAD_REQUEST, ) elif goal_key not in goal_options: return Response( - u'Provided goal key, {goal_key}, is not a valid goal key (options= {goal_options}).'.format( + 'Provided goal key, {goal_key}, is not a valid goal key (options= {goal_options}).'.format( goal_key=goal_key, goal_options=goal_options, ), @@ -83,7 +83,7 @@ class CourseGoalViewSet(viewsets.ModelViewSet): course_key = CourseKey.from_string(post_data.data['course_key']) if not course_key: return Response( - u'Provided course_key ({course_key}) does not map to a course.'.format( + 'Provided course_key ({course_key}) does not map to a course.'.format( course_key=course_key ), status=status.HTTP_400_BAD_REQUEST, diff --git a/lms/djangoapps/course_home_api/course_metadata/v1/tests/test_views.py b/lms/djangoapps/course_home_api/course_metadata/v1/tests/test_views.py index 28436a680c..04a3633be8 100644 --- a/lms/djangoapps/course_home_api/course_metadata/v1/tests/test_views.py +++ b/lms/djangoapps/course_home_api/course_metadata/v1/tests/test_views.py @@ -4,13 +4,12 @@ Tests for the Course Home Course Metadata API in the Course Home API import ddt - from django.urls import reverse from common.djangoapps.course_modes.models import CourseMode -from lms.djangoapps.course_home_api.tests.utils import BaseCourseHomeTests from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.student.tests.factories import UserFactory +from lms.djangoapps.course_home_api.tests.utils import BaseCourseHomeTests @ddt.ddt diff --git a/lms/djangoapps/course_home_api/course_metadata/v1/views.py b/lms/djangoapps/course_home_api/course_metadata/v1/views.py index c158071ffd..ed16ffb98e 100644 --- a/lms/djangoapps/course_home_api/course_metadata/v1/views.py +++ b/lms/djangoapps/course_home_api/course_metadata/v1/views.py @@ -2,6 +2,7 @@ General view for the Course Home that contains metadata every page needs. """ +from opaque_keys.edx.keys import CourseKey from rest_framework.generics import RetrieveAPIView from rest_framework.response import Response @@ -12,11 +13,11 @@ from edx_rest_framework_extensions.auth.session.authentication import SessionAut from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser from common.djangoapps.student.models import CourseEnrollment +from lms.djangoapps.course_api.api import course_detail +from lms.djangoapps.course_home_api.course_metadata.v1.serializers import CourseHomeMetadataSerializer from lms.djangoapps.courseware.access import has_access from lms.djangoapps.courseware.masquerade import setup_masquerade from lms.djangoapps.courseware.tabs import get_course_tab_list -from lms.djangoapps.course_api.api import course_detail -from lms.djangoapps.course_home_api.course_metadata.v1.serializers import CourseHomeMetadataSerializer class CourseHomeMetadataView(RetrieveAPIView): diff --git a/lms/djangoapps/course_home_api/dates/v1/serializers.py b/lms/djangoapps/course_home_api/dates/v1/serializers.py index db4c7abb74..9a8b6a37c6 100644 --- a/lms/djangoapps/course_home_api/dates/v1/serializers.py +++ b/lms/djangoapps/course_home_api/dates/v1/serializers.py @@ -6,8 +6,8 @@ Dates Tab Serializers. Represents the relevant dates for a Course. from rest_framework import serializers -from lms.djangoapps.courseware.date_summary import VerificationDeadlineDate from lms.djangoapps.course_home_api.mixins import DatesBannerSerializerMixin +from lms.djangoapps.courseware.date_summary import VerificationDeadlineDate class DateSummarySerializer(serializers.Serializer): diff --git a/lms/djangoapps/course_home_api/dates/v1/tests/test_views.py b/lms/djangoapps/course_home_api/dates/v1/tests/test_views.py index 436d56c4d6..0824b570cd 100644 --- a/lms/djangoapps/course_home_api/dates/v1/tests/test_views.py +++ b/lms/djangoapps/course_home_api/dates/v1/tests/test_views.py @@ -6,14 +6,14 @@ from datetime import datetime import ddt from django.urls import reverse +from edx_toggles.toggles.testutils import override_waffle_flag from common.djangoapps.course_modes.models import CourseMode -from edx_toggles.toggles.testutils import override_waffle_flag # lint-amnesty, pylint: disable=wrong-import-order +from common.djangoapps.student.models import CourseEnrollment from lms.djangoapps.course_home_api.tests.utils import BaseCourseHomeTests from lms.djangoapps.course_home_api.toggles import COURSE_HOME_MICROFRONTEND, COURSE_HOME_MICROFRONTEND_DATES_TAB from lms.djangoapps.experiments.testutils import override_experiment_waffle_flag from openedx.features.content_type_gating.models import ContentTypeGatingConfig -from common.djangoapps.student.models import CourseEnrollment @ddt.ddt diff --git a/lms/djangoapps/course_home_api/dates/v1/views.py b/lms/djangoapps/course_home_api/dates/v1/views.py index 0cc0595773..7d87e44792 100644 --- a/lms/djangoapps/course_home_api/dates/v1/views.py +++ b/lms/djangoapps/course_home_api/dates/v1/views.py @@ -2,23 +2,22 @@ Dates Tab Views """ +from django.http.response import Http404 +from edx_django_utils import monitoring as monitoring_utils +from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication +from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser +from opaque_keys.edx.keys import CourseKey from rest_framework.generics import RetrieveAPIView from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response -from edx_django_utils import monitoring as monitoring_utils -from django.http.response import Http404 -from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication -from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser -from opaque_keys.edx.keys import CourseKey - +from lms.djangoapps.course_home_api.dates.v1.serializers import DatesTabSerializer +from lms.djangoapps.course_home_api.toggles import course_home_mfe_dates_tab_is_active from lms.djangoapps.courseware.access import has_access from lms.djangoapps.courseware.context_processor import user_timezone_locale_prefs from lms.djangoapps.courseware.courses import get_course_date_blocks, get_course_with_access from lms.djangoapps.courseware.date_summary import TodaysDate from lms.djangoapps.courseware.masquerade import setup_masquerade -from lms.djangoapps.course_home_api.dates.v1.serializers import DatesTabSerializer -from lms.djangoapps.course_home_api.toggles import course_home_mfe_dates_tab_is_active from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser from openedx.features.content_type_gating.models import ContentTypeGatingConfig diff --git a/lms/djangoapps/course_home_api/outline/v1/tests/test_views.py b/lms/djangoapps/course_home_api/outline/v1/tests/test_views.py index 5ec718f8b4..b631697ebe 100644 --- a/lms/djangoapps/course_home_api/outline/v1/tests/test_views.py +++ b/lms/djangoapps/course_home_api/outline/v1/tests/test_views.py @@ -4,14 +4,16 @@ Tests for Outline Tab API in the Course Home API import itertools from datetime import datetime +from unittest.mock import Mock, patch import ddt -from edx_toggles.toggles.testutils import override_waffle_flag from django.conf import settings from django.urls import reverse -from mock import Mock, patch +from edx_toggles.toggles.testutils import override_waffle_flag from common.djangoapps.course_modes.models import CourseMode +from common.djangoapps.student.models import CourseEnrollment +from common.djangoapps.student.tests.factories import UserFactory from lms.djangoapps.course_home_api.tests.utils import BaseCourseHomeTests from lms.djangoapps.course_home_api.toggles import COURSE_HOME_MICROFRONTEND, COURSE_HOME_MICROFRONTEND_OUTLINE_TAB from lms.djangoapps.experiments.testutils import override_experiment_waffle_flag @@ -20,11 +22,11 @@ from openedx.core.djangoapps.user_api.preferences.api import set_user_preference from openedx.core.djangoapps.user_api.tests.factories import UserCourseTagFactory from openedx.features.course_duration_limits.models import CourseDurationLimitConfig from openedx.features.course_experience import ( - COURSE_ENABLE_UNENROLLED_ACCESS_FLAG, DISPLAY_COURSE_SOCK_FLAG, ENABLE_COURSE_GOALS, + COURSE_ENABLE_UNENROLLED_ACCESS_FLAG, + DISPLAY_COURSE_SOCK_FLAG, + ENABLE_COURSE_GOALS ) from openedx.features.discounts.applicability import DISCOUNT_APPLICABILITY_FLAG -from common.djangoapps.student.models import CourseEnrollment -from common.djangoapps.student.tests.factories import UserFactory from xmodule.course_module import COURSE_VISIBILITY_PUBLIC, COURSE_VISIBILITY_PUBLIC_OUTLINE from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory diff --git a/lms/djangoapps/course_home_api/outline/v1/views.py b/lms/djangoapps/course_home_api/outline/v1/views.py index 7fdb64407c..6e4516f991 100644 --- a/lms/djangoapps/course_home_api/outline/v1/views.py +++ b/lms/djangoapps/course_home_api/outline/v1/views.py @@ -2,6 +2,8 @@ Outline Tab Views """ +from completion.exceptions import UnavailableCompletionData +from completion.utilities import get_key_to_last_completed_block from django.http.response import Http404 from django.urls import reverse from django.utils.translation import gettext as _ @@ -15,14 +17,20 @@ from rest_framework.generics import RetrieveAPIView from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response -from completion.exceptions import UnavailableCompletionData -from completion.utilities import get_key_to_last_completed_block from common.djangoapps.course_modes.models import CourseMode -from lms.djangoapps.course_goals.api import (add_course_goal, get_course_goal, get_course_goal_text, - has_course_goal_permission, valid_course_goals_ordered) +from common.djangoapps.student.models import CourseEnrollment +from lms.djangoapps.course_goals.api import ( + add_course_goal, + get_course_goal, + get_course_goal_text, + has_course_goal_permission, + valid_course_goals_ordered +) from lms.djangoapps.course_home_api.outline.v1.serializers import OutlineTabSerializer -from lms.djangoapps.course_home_api.toggles import (course_home_mfe_dates_tab_is_active, - course_home_mfe_outline_tab_is_active) +from lms.djangoapps.course_home_api.toggles import ( + course_home_mfe_dates_tab_is_active, + course_home_mfe_outline_tab_is_active +) from lms.djangoapps.course_home_api.utils import get_microfrontend_url from lms.djangoapps.courseware.access import has_access from lms.djangoapps.courseware.context_processor import user_timezone_locale_prefs @@ -35,11 +43,11 @@ from openedx.features.course_duration_limits.access import get_access_expiration from openedx.features.course_experience import COURSE_ENABLE_UNENROLLED_ACCESS_FLAG from openedx.features.course_experience.course_tools import CourseToolsPluginManager from openedx.features.course_experience.course_updates import ( - dismiss_current_update_for_user, get_current_update_for_user, + dismiss_current_update_for_user, + get_current_update_for_user ) from openedx.features.course_experience.utils import get_course_outline_block_tree, get_start_block from openedx.features.discounts.utils import generate_offer_data -from common.djangoapps.student.models import CourseEnrollment from xmodule.course_module import COURSE_VISIBILITY_PUBLIC, COURSE_VISIBILITY_PUBLIC_OUTLINE from xmodule.modulestore.django import modulestore diff --git a/lms/djangoapps/course_home_api/progress/v1/serializers.py b/lms/djangoapps/course_home_api/progress/v1/serializers.py index ca4bb108fd..7de399d3b1 100644 --- a/lms/djangoapps/course_home_api/progress/v1/serializers.py +++ b/lms/djangoapps/course_home_api/progress/v1/serializers.py @@ -3,6 +3,7 @@ Progress Tab Serializers """ from rest_framework import serializers from rest_framework.reverse import reverse + from lms.djangoapps.certificates.models import CertificateStatuses diff --git a/lms/djangoapps/course_home_api/progress/v1/tests/test_views.py b/lms/djangoapps/course_home_api/progress/v1/tests/test_views.py index f172d17253..f157c53678 100644 --- a/lms/djangoapps/course_home_api/progress/v1/tests/test_views.py +++ b/lms/djangoapps/course_home_api/progress/v1/tests/test_views.py @@ -4,15 +4,15 @@ Tests for Progress Tab API in the Course Home API import ddt from django.urls import reverse +from edx_toggles.toggles.testutils import override_waffle_flag from common.djangoapps.course_modes.models import CourseMode -from edx_toggles.toggles.testutils import override_waffle_flag +from common.djangoapps.student.models import CourseEnrollment +from common.djangoapps.student.tests.factories import UserFactory from lms.djangoapps.course_home_api.tests.utils import BaseCourseHomeTests from lms.djangoapps.course_home_api.toggles import COURSE_HOME_MICROFRONTEND from lms.djangoapps.verify_student.models import ManualVerification from openedx.core.djangoapps.user_api.preferences.api import set_user_preference -from common.djangoapps.student.models import CourseEnrollment -from common.djangoapps.student.tests.factories import UserFactory CREDIT_SUPPORT_URL = 'https://support.edx.org/hc/en-us/sections/115004154688-Purchasing-Academic-Credit' diff --git a/lms/djangoapps/course_home_api/progress/v1/views.py b/lms/djangoapps/course_home_api/progress/v1/views.py index 4a821509bb..119b49a87b 100644 --- a/lms/djangoapps/course_home_api/progress/v1/views.py +++ b/lms/djangoapps/course_home_api/progress/v1/views.py @@ -2,23 +2,20 @@ Progress Tab Views """ +from edx_django_utils import monitoring as monitoring_utils +from opaque_keys.edx.keys import CourseKey from rest_framework.generics import RetrieveAPIView from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response -from edx_django_utils import monitoring as monitoring_utils -from opaque_keys.edx.keys import CourseKey - -from lms.djangoapps.course_home_api.progress.v1.serializers import ProgressTabSerializer - +import lms.djangoapps.course_blocks.api as course_blocks_api from common.djangoapps.student.models import CourseEnrollment from lms.djangoapps.course_api.blocks.transformers.blocks_api import BlocksAPITransformer +from lms.djangoapps.course_home_api.progress.v1.serializers import ProgressTabSerializer +from lms.djangoapps.courseware.access import has_access from lms.djangoapps.courseware.context_processor import user_timezone_locale_prefs from lms.djangoapps.courseware.courses import get_course_with_access, get_studio_url from lms.djangoapps.courseware.masquerade import setup_masquerade -from lms.djangoapps.courseware.access import has_access - -import lms.djangoapps.course_blocks.api as course_blocks_api from lms.djangoapps.courseware.views.views import credit_course_requirements, get_cert_data from lms.djangoapps.grades.api import CourseGradeFactory from lms.djangoapps.verify_student.services import IDVerificationService diff --git a/lms/djangoapps/course_home_api/tests/utils.py b/lms/djangoapps/course_home_api/tests/utils.py index 9abb980556..509bd490ec 100644 --- a/lms/djangoapps/course_home_api/tests/utils.py +++ b/lms/djangoapps/course_home_api/tests/utils.py @@ -3,8 +3,8 @@ Base classes or util functions for use in Course Home API tests """ import unittest - from datetime import datetime + from django.conf import settings from common.djangoapps.course_modes.models import CourseMode @@ -12,7 +12,10 @@ from common.djangoapps.course_modes.tests.factories import CourseModeFactory from lms.djangoapps.courseware.tests.helpers import MasqueradeMixin from lms.djangoapps.verify_student.models import VerificationDeadline from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory -from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase # lint-amnesty, pylint: disable=unused-import +from xmodule.modulestore.tests.django_utils import ( # lint-amnesty, pylint: disable=unused-import + TEST_DATA_SPLIT_MODULESTORE, + ModuleStoreTestCase +) from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory diff --git a/lms/djangoapps/course_home_api/toggles.py b/lms/djangoapps/course_home_api/toggles.py index c65387aaa0..cefe4909ca 100644 --- a/lms/djangoapps/course_home_api/toggles.py +++ b/lms/djangoapps/course_home_api/toggles.py @@ -3,6 +3,7 @@ Toggles for course home experience. """ from edx_toggles.toggles import LegacyWaffleFlagNamespace + from lms.djangoapps.experiments.flags import ExperimentWaffleFlag from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag diff --git a/lms/djangoapps/course_home_api/urls.py b/lms/djangoapps/course_home_api/urls.py index 83bf406a64..e15585e30c 100644 --- a/lms/djangoapps/course_home_api/urls.py +++ b/lms/djangoapps/course_home_api/urls.py @@ -6,8 +6,8 @@ Contains all the URLs for the Course Home from django.conf import settings from django.urls import re_path -from lms.djangoapps.course_home_api.dates.v1.views import DatesTabView from lms.djangoapps.course_home_api.course_metadata.v1.views import CourseHomeMetadataView +from lms.djangoapps.course_home_api.dates.v1.views import DatesTabView from lms.djangoapps.course_home_api.outline.v1.views import OutlineTabView, dismiss_welcome_message, save_course_goal from lms.djangoapps.course_home_api.progress.v1.views import ProgressTabView @@ -16,7 +16,7 @@ urlpatterns = [] # URL for Course metadata content urlpatterns += [ re_path( - r'v1/course_metadata/{}'.format(settings.COURSE_KEY_PATTERN), + fr'v1/course_metadata/{settings.COURSE_KEY_PATTERN}', CourseHomeMetadataView.as_view(), name='course-home-course-metadata' ), @@ -25,7 +25,7 @@ urlpatterns += [ # Dates Tab URLs urlpatterns += [ re_path( - r'v1/dates/{}'.format(settings.COURSE_KEY_PATTERN), + fr'v1/dates/{settings.COURSE_KEY_PATTERN}', DatesTabView.as_view(), name='course-home-dates-tab' ), @@ -34,7 +34,7 @@ urlpatterns += [ # Outline Tab URLs urlpatterns += [ re_path( - r'v1/outline/{}'.format(settings.COURSE_KEY_PATTERN), + fr'v1/outline/{settings.COURSE_KEY_PATTERN}', OutlineTabView.as_view(), name='course-home-outline-tab' ), @@ -59,7 +59,7 @@ urlpatterns += [ # Progress Tab URLs urlpatterns += [ re_path( - r'v1/progress/{}'.format(settings.COURSE_KEY_PATTERN), + fr'v1/progress/{settings.COURSE_KEY_PATTERN}', ProgressTabView.as_view(), name='course-home-progress-tab' ), diff --git a/lms/djangoapps/course_home_api/utils.py b/lms/djangoapps/course_home_api/utils.py index f6a5060f61..220270013d 100644 --- a/lms/djangoapps/course_home_api/utils.py +++ b/lms/djangoapps/course_home_api/utils.py @@ -7,10 +7,10 @@ def get_microfrontend_url(course_key, view_name=None): """ Takes in a course key and view name, returns the appropriate course home mfe route """ - mfe_link = '{}/course/{}'.format(settings.LEARNING_MICROFRONTEND_URL, course_key) + mfe_link = f'{settings.LEARNING_MICROFRONTEND_URL}/course/{course_key}' if view_name: - mfe_link += '/{}'.format(view_name) + mfe_link += f'/{view_name}' return mfe_link