Merge pull request #26522 from edx/usamasadiq/bom-2356-pyupgrade
Ran pyupgrade on lms/djangoapps
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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']
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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')]
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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')},
|
||||
),
|
||||
]
|
||||
|
||||
@@ -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')]),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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'
|
||||
),
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user