From 49ae6b9d7376ab770c2dc585776bc468593b4281 Mon Sep 17 00:00:00 2001 From: Matthew Piatetsky Date: Thu, 7 Mar 2019 11:50:36 -0500 Subject: [PATCH] Remove CONTENT_TYPE_GATING flag --- cms/djangoapps/contentstore/utils.py | 5 ++-- lms/djangoapps/course_api/tests/test_views.py | 2 +- .../grades/tests/test_course_grade_factory.py | 2 +- .../tests/test_tasks_helper.py | 2 +- .../features/content_type_gating/models.py | 10 -------- .../content_type_gating/tests/test_models.py | 11 ++------- .../features/course_duration_limits/config.py | 6 ----- .../features/course_duration_limits/models.py | 10 -------- .../tests/test_models.py | 23 ++----------------- 9 files changed, 9 insertions(+), 62 deletions(-) diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index 7c55ec65dd..bc4f14b072 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -18,7 +18,6 @@ from django_comment_common.models import assign_default_role from django_comment_common.utils import seed_permissions_roles from openedx.core.djangoapps.site_configuration.models import SiteConfiguration from openedx.features.course_duration_limits.config import ( - CONTENT_TYPE_GATING_FLAG, FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG ) from openedx.features.content_type_gating.models import ContentTypeGatingConfig @@ -465,11 +464,11 @@ def get_visibility_partition_info(xblock, course=None): if len(partition["groups"]) > 1 or any(group["selected"] for group in partition["groups"]): selectable_partitions.append(partition) - flag_enabled = CONTENT_TYPE_GATING_FLAG.is_enabled() and not FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled() + kill_flag_disabled = not FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled() course_key = xblock.scope_ids.usage_id.course_key is_library = isinstance(course_key, LibraryLocator) if not is_library and ( - flag_enabled or ContentTypeGatingConfig.current(course_key=course_key).studio_override_enabled + kill_flag_disabled and ContentTypeGatingConfig.current(course_key=course_key).studio_override_enabled ): selectable_partitions += get_user_partition_info(xblock, schemes=[CONTENT_TYPE_GATING_SCHEME], course=course) diff --git a/lms/djangoapps/course_api/tests/test_views.py b/lms/djangoapps/course_api/tests/test_views.py index 012a5495a5..4ca9cecf2a 100644 --- a/lms/djangoapps/course_api/tests/test_views.py +++ b/lms/djangoapps/course_api/tests/test_views.py @@ -387,7 +387,7 @@ class CourseListSearchViewTest(CourseApiTestViewMixin, ModuleStoreTestCase, Sear self.setup_user(self.audit_user) # These query counts were found empirically - query_counts = [65, 52, 52, 52, 52, 52, 52, 52, 52, 52, 22] + query_counts = [64, 51, 51, 51, 51, 51, 51, 51, 51, 51, 21] ordered_course_ids = sorted([str(cid) for cid in (course_ids + [c.id for c in self.courses])]) self.clear_caches() diff --git a/lms/djangoapps/grades/tests/test_course_grade_factory.py b/lms/djangoapps/grades/tests/test_course_grade_factory.py index 3ac5969fdb..6ddbfd1be7 100644 --- a/lms/djangoapps/grades/tests/test_course_grade_factory.py +++ b/lms/djangoapps/grades/tests/test_course_grade_factory.py @@ -313,7 +313,7 @@ class TestGradeIteration(SharedModuleStoreTestCase): else mock_course_grade.return_value for student in self.students ] - with self.assertNumQueries(9): + with self.assertNumQueries(8): all_course_grades, all_errors = self._course_grades_and_errors_for(self.course, self.students) self.assertEqual( {student: text_type(all_errors[student]) for student in all_errors}, diff --git a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py index ff6ca4dd50..40c53951c3 100644 --- a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py +++ b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py @@ -413,7 +413,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase): RequestCache.clear_all_namespaces() - expected_query_count = 50 + expected_query_count = 49 with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'): with check_mongo_calls(mongo_count): with self.assertNumQueries(expected_query_count): diff --git a/openedx/features/content_type_gating/models.py b/openedx/features/content_type_gating/models.py index ee08d85410..ddabb2f276 100644 --- a/openedx/features/content_type_gating/models.py +++ b/openedx/features/content_type_gating/models.py @@ -22,7 +22,6 @@ from openedx.core.djangoapps.config_model_utils.models import StackedConfigurati from openedx.core.djangoapps.config_model_utils.utils import is_in_holdback from openedx.features.content_type_gating.helpers import FULL_ACCESS, LIMITED_ACCESS from openedx.features.course_duration_limits.config import ( - CONTENT_TYPE_GATING_FLAG, FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG, ) from student.models import CourseEnrollment @@ -109,9 +108,6 @@ class ContentTypeGatingConfig(StackedConfigurationModel): if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled(): return False - if CONTENT_TYPE_GATING_FLAG.is_enabled(): - return True - if enrollment is not None and (user is not None or course_key is not None): raise ValueError('Specify enrollment or user/course_key, but not both') @@ -175,9 +171,6 @@ class ContentTypeGatingConfig(StackedConfigurationModel): if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled(): return False - if CONTENT_TYPE_GATING_FLAG.is_enabled(): - return True - if target_datetime is None: target_datetime = timezone.now() @@ -199,9 +192,6 @@ class ContentTypeGatingConfig(StackedConfigurationModel): if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled(): return False - if CONTENT_TYPE_GATING_FLAG.is_enabled(): - return True - # Explicitly cast this to bool, so that when self.enabled is None the method doesn't return None return bool(self.enabled and self.enabled_as_of <= target_datetime) diff --git a/openedx/features/content_type_gating/tests/test_models.py b/openedx/features/content_type_gating/tests/test_models.py index aca44f17bc..06385ced65 100644 --- a/openedx/features/content_type_gating/tests/test_models.py +++ b/openedx/features/content_type_gating/tests/test_models.py @@ -14,7 +14,6 @@ from openedx.core.djangoapps.site_configuration.tests.factories import SiteConfi from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag from openedx.core.djangolib.testing.utils import CacheIsolationTestCase from openedx.features.content_type_gating.models import ContentTypeGatingConfig -from openedx.features.course_duration_limits.config import CONTENT_TYPE_GATING_FLAG from student.tests.factories import CourseEnrollmentFactory, UserFactory @@ -74,9 +73,9 @@ class TestContentTypeGatingConfig(CacheIsolationTestCase): user = self.user course_key = self.course_overview.id - query_count = 8 + query_count = 7 if not already_enrolled or not pass_enrollment and already_enrolled: - query_count = 9 + query_count = 8 with self.assertNumQueries(query_count): enabled = ContentTypeGatingConfig.enabled_for_enrollment( @@ -94,12 +93,6 @@ class TestContentTypeGatingConfig(CacheIsolationTestCase): with self.assertRaises(ValueError): ContentTypeGatingConfig.enabled_for_enrollment(Mock(name='enrollment'), None, Mock(name='course_key')) - @override_waffle_flag(CONTENT_TYPE_GATING_FLAG, True) - def test_enabled_for_enrollment_flag_override(self): - self.assertTrue(ContentTypeGatingConfig.enabled_for_enrollment(None, None, None)) - self.assertTrue(ContentTypeGatingConfig.enabled_for_enrollment(Mock(name='enrollment'), Mock(name='user'), None)) - self.assertTrue(ContentTypeGatingConfig.enabled_for_enrollment(Mock(name='enrollment'), None, Mock(name='course_key'))) - @ddt.data(True, False) def test_enabled_for_course( self, diff --git a/openedx/features/course_duration_limits/config.py b/openedx/features/course_duration_limits/config.py index 91c988e5b9..9f6cf7ae55 100644 --- a/openedx/features/course_duration_limits/config.py +++ b/openedx/features/course_duration_limits/config.py @@ -14,12 +14,6 @@ from student.signals import ENROLL_STATUS_CHANGE WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name=u'content_type_gating') -CONTENT_TYPE_GATING_FLAG = WaffleFlag( - waffle_namespace=WAFFLE_FLAG_NAMESPACE, - flag_name=u'debug', - flag_undefined_default=False -) - FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG = WaffleFlag( waffle_namespace=WAFFLE_FLAG_NAMESPACE, flag_name=u'global_kill_switch', diff --git a/openedx/features/course_duration_limits/models.py b/openedx/features/course_duration_limits/models.py index cfeebf67a6..9a37105b3c 100644 --- a/openedx/features/course_duration_limits/models.py +++ b/openedx/features/course_duration_limits/models.py @@ -22,7 +22,6 @@ from openedx.core.djangoapps.config_model_utils.models import StackedConfigurati from openedx.core.djangoapps.config_model_utils.utils import is_in_holdback from openedx.features.content_type_gating.helpers 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, ) from student.models import CourseEnrollment @@ -100,9 +99,6 @@ class CourseDurationLimitConfig(StackedConfigurationModel): if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled(): return False - if CONTENT_TYPE_GATING_FLAG.is_enabled(): - return True - if enrollment is not None and (user is not None or course_key is not None): raise ValueError('Specify enrollment or user/course_key, but not both') @@ -170,9 +166,6 @@ class CourseDurationLimitConfig(StackedConfigurationModel): if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled(): return False - if CONTENT_TYPE_GATING_FLAG.is_enabled(): - return True - if target_datetime is None: target_datetime = timezone.now() @@ -194,9 +187,6 @@ class CourseDurationLimitConfig(StackedConfigurationModel): if FEATURE_BASED_ENROLLMENT_GLOBAL_KILL_FLAG.is_enabled(): return True - if CONTENT_TYPE_GATING_FLAG.is_enabled(): - return True - # Explicitly cast this to bool, so that when self.enabled is None the method doesn't return None return bool(self.enabled and self.enabled_as_of <= target_datetime) diff --git a/openedx/features/course_duration_limits/tests/test_models.py b/openedx/features/course_duration_limits/tests/test_models.py index 584a4b210b..9bd30a7f29 100644 --- a/openedx/features/course_duration_limits/tests/test_models.py +++ b/openedx/features/course_duration_limits/tests/test_models.py @@ -18,7 +18,6 @@ from openedx.core.djangoapps.content.course_overviews.tests.factories import Cou from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag from openedx.core.djangolib.testing.utils import CacheIsolationTestCase from openedx.features.course_duration_limits.models import CourseDurationLimitConfig -from openedx.features.course_duration_limits.config import CONTENT_TYPE_GATING_FLAG from student.tests.factories import CourseEnrollmentFactory, UserFactory @@ -81,9 +80,9 @@ class TestCourseDurationLimitConfig(CacheIsolationTestCase): user = self.user course_key = self.course_overview.id - query_count = 9 + query_count = 8 if pass_enrollment and already_enrolled: - query_count = 8 + query_count = 7 with self.assertNumQueries(query_count): enabled = CourseDurationLimitConfig.enabled_for_enrollment( @@ -109,24 +108,6 @@ class TestCourseDurationLimitConfig(CacheIsolationTestCase): Mock(name='course_key') ) - @override_waffle_flag(CONTENT_TYPE_GATING_FLAG, True) - def test_enabled_for_enrollment_flag_override(self): - self.assertTrue(CourseDurationLimitConfig.enabled_for_enrollment( - None, - None, - None - )) - self.assertTrue(CourseDurationLimitConfig.enabled_for_enrollment( - Mock(name='enrollment'), - Mock(name='user'), - None - )) - self.assertTrue(CourseDurationLimitConfig.enabled_for_enrollment( - Mock(name='enrollment'), - None, - Mock(name='course_key') - )) - @ddt.data(True, False) def test_enabled_for_course( self,