REVE-154 FBE Global Kill Switch

Create a global kill switch for feature based enrollment.  To turn on
the kill switch (and turn off both course duration gating and content
type gating) enable a waffle flag named:
'content_type_gating.global_kill_switch'
This commit is contained in:
Bessie Steinberg
2018-12-13 13:30:06 -05:00
parent da2319cac1
commit 6f2a2785e8
8 changed files with 43 additions and 12 deletions

View File

@@ -17,6 +17,7 @@ from openedx.core.djangoapps.config_model_utils.models import StackedConfigurati
from openedx.features.content_type_gating.helpers import has_staff_roles
from openedx.features.course_duration_limits.config import (
CONTENT_TYPE_GATING_FLAG,
FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG,
EXPERIMENT_ID,
EXPERIMENT_DATA_HOLDBACK_KEY
)
@@ -68,6 +69,9 @@ class ContentTypeGatingConfig(StackedConfigurationModel):
user: The user being queried.
course_key: The CourseKey of the course being queried.
"""
if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled():
return False
if CONTENT_TYPE_GATING_FLAG.is_enabled():
return True
@@ -141,6 +145,10 @@ class ContentTypeGatingConfig(StackedConfigurationModel):
course_key: The CourseKey of the course being queried.
target_datetime: The datetime to checked enablement as of. Defaults to the current date and time.
"""
if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled():
return False
if CONTENT_TYPE_GATING_FLAG.is_enabled():
return True
@@ -161,6 +169,10 @@ class ContentTypeGatingConfig(StackedConfigurationModel):
Arguments:
target_datetime (:class:`datetime.datetime`): The datetime that ``enabled_as_of`` must be equal to or before
"""
if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled():
return False
if CONTENT_TYPE_GATING_FLAG.is_enabled():
return True

View File

@@ -73,12 +73,9 @@ class TestContentTypeGatingConfig(CacheIsolationTestCase):
user = self.user
course_key = self.course_overview.id
if already_enrolled and pass_enrollment:
query_count = 7
elif not pass_enrollment and already_enrolled:
query_count = 8
else:
query_count = 7
query_count = 8
if not pass_enrollment and already_enrolled:
query_count = 9
with self.assertNumQueries(query_count):
enabled = ContentTypeGatingConfig.enabled_for_enrollment(

View File

@@ -19,6 +19,12 @@ CONTENT_TYPE_GATING_FLAG = WaffleFlag(
flag_undefined_default=False
)
FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG = WaffleFlag(
waffle_namespace=WAFFLE_FLAG_NAMESPACE,
flag_name=u'global_kill_switch',
flag_undefined_default=False
)
EXPERIMENT_ID = 11
EXPERIMENT_DATA_HOLDBACK_KEY = 'holdback'

View File

@@ -24,6 +24,7 @@ from openedx.features.content_type_gating.helpers import has_staff_roles
from openedx.features.content_type_gating.partitions import CONTENT_GATING_PARTITION_ID, CONTENT_TYPE_GATE_GROUP_IDS
from openedx.features.course_duration_limits.config import (
CONTENT_TYPE_GATING_FLAG,
FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG,
EXPERIMENT_ID,
EXPERIMENT_DATA_HOLDBACK_KEY
)
@@ -95,6 +96,10 @@ class CourseDurationLimitConfig(StackedConfigurationModel):
user: The user being queried.
course_key: The CourseKey of the course being queried.
"""
if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled():
return False
if CONTENT_TYPE_GATING_FLAG.is_enabled():
return True
@@ -163,6 +168,10 @@ class CourseDurationLimitConfig(StackedConfigurationModel):
course_key: The CourseKey of the course being queried.
target_datetime: The datetime to checked enablement as of. Defaults to the current date and time.
"""
if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled():
return False
if CONTENT_TYPE_GATING_FLAG.is_enabled():
return True
@@ -183,6 +192,10 @@ class CourseDurationLimitConfig(StackedConfigurationModel):
Arguments:
target_datetime (:class:`datetime.datetime`): The datetime that ``enabled_as_of`` must be equal to or before
"""
if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled():
return True
if CONTENT_TYPE_GATING_FLAG.is_enabled():
return True

View File

@@ -80,9 +80,9 @@ class TestCourseDurationLimitConfig(CacheIsolationTestCase):
user = self.user
course_key = self.course_overview.id
query_count = 7
query_count = 8
if not pass_enrollment and already_enrolled:
query_count = 8
query_count = 9
with self.assertNumQueries(query_count):
enabled = CourseDurationLimitConfig.enabled_for_enrollment(