Add an automatic UserPartition and Scheme for Content Type Gating.

For now, this UserPartition groups all users as Full-access users.
This commit is contained in:
Calen Pennington
2018-10-02 13:45:22 -04:00
parent 0adb654724
commit 99f8918b74
6 changed files with 186 additions and 4 deletions

View File

@@ -8,7 +8,15 @@ from django.utils.translation import ugettext_lazy as _
import logging
from openedx.core.lib.cache_utils import request_cached
from xmodule.partitions.partitions import UserPartition, UserPartitionError, ENROLLMENT_TRACK_PARTITION_ID
from openedx.features.content_type_gating.partitions import (
CONTENT_GATING_PARTITION_ID,
create_content_gating_partition,
)
from xmodule.partitions.partitions import (
UserPartition,
UserPartitionError,
ENROLLMENT_TRACK_PARTITION_ID,
)
from xmodule.modulestore.django import modulestore
@@ -42,8 +50,14 @@ def _get_dynamic_partitions(course):
Return the dynamic user partitions for this course.
If none exists, returns an empty array.
"""
enrollment_partition = _create_enrollment_track_partition(course)
return [enrollment_partition] if enrollment_partition else []
return [
partition
for partition in [
_create_enrollment_track_partition(course),
create_content_gating_partition(course),
]
if partition
]
def _create_enrollment_track_partition(course):

View File

@@ -127,6 +127,19 @@ class SplitTestModuleLMSTest(SplitTestModuleTest):
"""
shard = 1
def setUp(self):
super(SplitTestModuleLMSTest, self).setUp()
content_gating_flag_patcher = patch(
'openedx.features.content_type_gating.partitions.CONTENT_TYPE_GATING_FLAG.is_enabled',
return_value=False,
).start()
self.addCleanup(content_gating_flag_patcher.stop)
content_gating_ui_flag_patcher = patch(
'openedx.features.content_type_gating.partitions.CONTENT_TYPE_GATING_STUDIO_UI_FLAG.is_enabled',
return_value=False,
).start()
self.addCleanup(content_gating_ui_flag_patcher.stop)
@ddt.data((0, 'split_test_cond0'), (1, 'split_test_cond1'))
@ddt.unpack
def test_child(self, user_tag, child_url_name):