REVE-37: Prevent modifications to feature based enrollment user partitions
This commit is contained in:
@@ -49,22 +49,14 @@ class EnrollmentTrackUserPartition(UserPartition):
|
||||
for mode in CourseMode.modes_for_course(course_key, include_expired=True)
|
||||
]
|
||||
|
||||
def from_json(self):
|
||||
"""
|
||||
Because this partition is dynamic, `from_json` is not supported.
|
||||
`to_json` is supported, but shouldn't be used to persist this partition
|
||||
within the course itself (used by Studio for sending data to front-end code)
|
||||
|
||||
Calling this method will raise a TypeError.
|
||||
"""
|
||||
raise TypeError("Because EnrollmentTrackUserPartition is a dynamic partition, 'from_json' is not supported.")
|
||||
|
||||
|
||||
class EnrollmentTrackPartitionScheme(object):
|
||||
"""
|
||||
This scheme uses learner enrollment tracks to map learners into partition groups.
|
||||
"""
|
||||
|
||||
read_only = True
|
||||
|
||||
@classmethod
|
||||
def get_group_for_user(cls, course_key, user, user_partition, **kwargs): # pylint: disable=unused-argument
|
||||
"""
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
Tests for verified_track_content/partition_scheme.py.
|
||||
"""
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytz
|
||||
|
||||
from ..partition_scheme import EnrollmentTrackPartitionScheme, EnrollmentTrackUserPartition, ENROLLMENT_GROUP_IDS
|
||||
from ..models import VerifiedTrackCohortedCourse
|
||||
from course_modes.models import CourseMode
|
||||
|
||||
from student.models import CourseEnrollment
|
||||
from student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.partitions.partitions import UserPartition, MINIMUM_STATIC_PARTITION_ID
|
||||
from xmodule.partitions.partitions import MINIMUM_STATIC_PARTITION_ID, UserPartition, ReadOnlyUserPartitionError
|
||||
|
||||
from ..models import VerifiedTrackCohortedCourse
|
||||
from ..partition_scheme import ENROLLMENT_GROUP_IDS, EnrollmentTrackPartitionScheme, EnrollmentTrackUserPartition
|
||||
|
||||
|
||||
class EnrollmentTrackUserPartitionTest(SharedModuleStoreTestCase):
|
||||
@@ -60,8 +61,9 @@ class EnrollmentTrackUserPartitionTest(SharedModuleStoreTestCase):
|
||||
self.assertEqual('Test partition for segmenting users by enrollment track', user_partition_json['description'])
|
||||
|
||||
def test_from_json_not_supported(self):
|
||||
with self.assertRaises(TypeError):
|
||||
EnrollmentTrackUserPartition.from_json()
|
||||
user_partition_json = create_enrollment_track_partition(self.course).to_json()
|
||||
with self.assertRaises(ReadOnlyUserPartitionError):
|
||||
UserPartition.from_json(user_partition_json)
|
||||
|
||||
def test_group_ids(self):
|
||||
"""
|
||||
|
||||
@@ -127,6 +127,8 @@ class ContentTypeGatingPartitionScheme(object):
|
||||
LIMITED_ACCESS = Group(CONTENT_TYPE_GATE_GROUP_IDS['limited_access'], 'Limited-access Users')
|
||||
FULL_ACCESS = Group(CONTENT_TYPE_GATE_GROUP_IDS['full_access'], 'Full-access Users')
|
||||
|
||||
read_only = True
|
||||
|
||||
@classmethod
|
||||
def get_group_for_user(cls, course_key, user, user_partition, **kwargs): # pylint: disable=unused-argument
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user