refactor: move waffle flag calculation to utils file and other updates
This commit is contained in:
@@ -34,8 +34,10 @@ from common.djangoapps.student.roles import CourseInstructorRole, CourseStaffRol
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from common.djangoapps.util import milestones_helpers
|
||||
from common.djangoapps.xblock_django.models import XBlockStudioConfigurationFlag
|
||||
from openedx.core.djangoapps.discussions.config.waffle import ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND, \
|
||||
from openedx.core.djangoapps.discussions.config.waffle import (
|
||||
ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND,
|
||||
OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG
|
||||
)
|
||||
from openedx.core.djangoapps.models.course_details import CourseDetails
|
||||
from xmodule.fields import Date
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
@@ -125,7 +127,8 @@ class CourseAdvanceSettingViewTest(CourseTestCase, MilestonesTestCaseMixin):
|
||||
@ddt.data(
|
||||
(False, False, True),
|
||||
(True, False, False),
|
||||
(True, True, True)
|
||||
(True, True, True),
|
||||
(False, True, True)
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_discussion_fields_available(self, is_pages_and_resources_enabled,
|
||||
|
||||
@@ -14,8 +14,7 @@ from xblock.fields import Scope
|
||||
|
||||
from cms.djangoapps.contentstore import toggles
|
||||
from common.djangoapps.xblock_django.models import XBlockStudioConfigurationFlag
|
||||
from openedx.core.djangoapps.discussions.config.waffle import OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG, \
|
||||
ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND
|
||||
from openedx.core.djangoapps.discussions.config.waffle_utils import legacy_discussion_experience_enabled
|
||||
from openedx.core.lib.teams_config import TeamsetType
|
||||
from openedx.features.course_experience import COURSE_ENABLE_UNENROLLED_ACCESS_FLAG
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -143,8 +142,7 @@ class CourseMetadata:
|
||||
if not settings.PROCTORING_BACKENDS or settings.PROCTORING_BACKENDS.get('proctortrack') is None:
|
||||
exclude_list.append('proctoring_escalation_email')
|
||||
|
||||
if (ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND.is_enabled(course_key) and
|
||||
not OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG.is_enabled(course_key)):
|
||||
if not legacy_discussion_experience_enabled(course_key):
|
||||
exclude_list.append('discussion_blackouts')
|
||||
exclude_list.append('allow_anonymous')
|
||||
exclude_list.append('allow_anonymous_to_peers')
|
||||
|
||||
@@ -30,8 +30,10 @@ from lms.djangoapps.grades.config.waffle import WRITABLE_GRADEBOOK, waffle_flags
|
||||
from lms.djangoapps.instructor.toggles import DATA_DOWNLOAD_V2
|
||||
from lms.djangoapps.instructor.views.gradebook_api import calculate_page_info
|
||||
from openedx.core.djangoapps.course_groups.cohorts import set_course_cohorted
|
||||
from openedx.core.djangoapps.discussions.config.waffle import ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND, \
|
||||
from openedx.core.djangoapps.discussions.config.waffle import (
|
||||
ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND,
|
||||
OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG
|
||||
)
|
||||
from openedx.core.djangoapps.site_configuration.models import SiteConfiguration
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase
|
||||
|
||||
@@ -52,8 +52,7 @@ from lms.djangoapps.courseware.module_render import get_module_by_usage_id
|
||||
from lms.djangoapps.discussion.django_comment_client.utils import available_division_schemes, has_forum_access
|
||||
from lms.djangoapps.grades.api import is_writable_gradebook_enabled
|
||||
from openedx.core.djangoapps.course_groups.cohorts import DEFAULT_COHORT_NAME, get_course_cohorts, is_course_cohorted
|
||||
from openedx.core.djangoapps.discussions.config.waffle import ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND, \
|
||||
OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG
|
||||
from openedx.core.djangoapps.discussions.config.waffle_utils import legacy_discussion_experience_enabled
|
||||
from openedx.core.djangoapps.django_comment_common.models import FORUM_ROLE_ADMINISTRATOR, CourseDiscussionSettings
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.djangoapps.verified_track_content.models import VerifiedTrackCohortedCourse
|
||||
@@ -142,11 +141,7 @@ def instructor_dashboard_2(request, course_id): # lint-amnesty, pylint: disable
|
||||
_section_student_admin(course, access),
|
||||
]
|
||||
|
||||
discussion_section_visible = bool((ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND.is_enabled(course_key) and
|
||||
OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG.is_enabled(course_key)) or not
|
||||
ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND.is_enabled(course_key))
|
||||
|
||||
if discussion_section_visible:
|
||||
if legacy_discussion_experience_enabled(course_key):
|
||||
sections_content.append(_section_discussions_management(course, access))
|
||||
sections.extend(sections_content)
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG = CourseWaffleFlag(
|
||||
# .. toggle_name: discussions.pages_and_resources_mfe
|
||||
# .. toggle_implementation: CourseWaffleFlag
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Waffle flag to link existing studio views to the new Pages and Resources experience.
|
||||
# .. toggle_description: Waffle flag to enable new Pages and Resources experience for course.
|
||||
# .. toggle_use_cases: temporary, open_edx
|
||||
# .. toggle_creation_date: 2021-05-24
|
||||
# .. toggle_target_removal_date: 2021-12-31
|
||||
# .. toggle_warnings: Also set settings.COURSE_AUTHORING_MICROFRONTEND_URL.
|
||||
# .. toggle_tickets: None
|
||||
# .. toggle_tickets: https://openedx.atlassian.net/browse/TNL-7791
|
||||
ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND = CourseWaffleFlag(
|
||||
waffle_namespace=WAFFLE_NAMESPACE,
|
||||
flag_name='pages_and_resources_mfe',
|
||||
|
||||
16
openedx/core/djangoapps/discussions/config/waffle_utils.py
Normal file
16
openedx/core/djangoapps/discussions/config/waffle_utils.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
Utils methods for Discussion app waffle flags.
|
||||
"""
|
||||
|
||||
from openedx.core.djangoapps.discussions.config.waffle import (
|
||||
ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND,
|
||||
OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG
|
||||
)
|
||||
|
||||
|
||||
def legacy_discussion_experience_enabled(course_key):
|
||||
"""
|
||||
Checks for relevant flags and returns a boolean whether to show legacy discussion settings or not
|
||||
"""
|
||||
return bool(OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG.is_enabled(course_key) or
|
||||
not ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND.is_enabled(course_key))
|
||||
Reference in New Issue
Block a user