chore: removed and merged multiple flags into enable_discussions_mfe flag (#33983)
This commit is contained in:
@@ -146,7 +146,6 @@ class CourseMetadata:
|
||||
exclude_list.append('allow_anonymous')
|
||||
exclude_list.append('allow_anonymous_to_peers')
|
||||
exclude_list.append('discussion_topics')
|
||||
|
||||
return exclude_list
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
"""
|
||||
This module contains configuration settings via waffle switches for the discussions.
|
||||
"""
|
||||
|
||||
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag
|
||||
|
||||
WAFFLE_NAMESPACE = 'discussions'
|
||||
|
||||
# .. toggle_name: discussions.enable_learners_stats
|
||||
# .. toggle_implementation: CourseWaffleFlag
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Waffle flag to enable learners stats
|
||||
# .. toggle_use_cases: temporary, open_edx
|
||||
# .. toggle_creation_date: 2022-08-12
|
||||
# .. toggle_target_removal_date: 2022-10-02
|
||||
# .. toggle_warning: When the flag is ON, API will return learners stats with original values.
|
||||
# .. This is temporary fix for performance issue in API.
|
||||
# .. toggle_tickets: INF-444
|
||||
ENABLE_LEARNERS_STATS = CourseWaffleFlag(f'{WAFFLE_NAMESPACE}.enable_learners_stats', __name__)
|
||||
@@ -37,7 +37,7 @@ from lms.djangoapps.course_api.blocks.api import get_blocks
|
||||
from lms.djangoapps.course_blocks.api import get_course_blocks
|
||||
from lms.djangoapps.courseware.courses import get_course_with_access
|
||||
from lms.djangoapps.courseware.exceptions import CourseAccessRedirect
|
||||
from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE, ENABLE_LEARNERS_TAB_IN_DISCUSSIONS_MFE
|
||||
from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE
|
||||
from lms.djangoapps.discussion.views import is_privileged_user
|
||||
from openedx.core.djangoapps.discussions.models import (
|
||||
DiscussionsConfiguration,
|
||||
@@ -85,7 +85,6 @@ from xmodule.course_block import CourseBlock
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.tabs import CourseTabList
|
||||
|
||||
from ..config.waffle import ENABLE_LEARNERS_STATS
|
||||
from ..django_comment_client.base.views import (
|
||||
track_comment_created_event,
|
||||
track_comment_deleted_event,
|
||||
@@ -365,7 +364,6 @@ def get_course(request, course_key):
|
||||
"provider": course_config.provider_type,
|
||||
"enable_in_context": course_config.enable_in_context,
|
||||
"group_at_subsection": course_config.plugin_configuration.get("group_at_subsection", False),
|
||||
'learners_tab_enabled': ENABLE_LEARNERS_TAB_IN_DISCUSSIONS_MFE.is_enabled(course_key),
|
||||
"edit_reasons": [
|
||||
{"code": reason_code, "label": label}
|
||||
for (reason_code, label) in EDIT_REASON_CODES.items()
|
||||
@@ -1857,16 +1855,6 @@ def get_course_discussion_user_stats(
|
||||
if order_by == UserOrdering.BY_FLAGS:
|
||||
raise ValidationError({"order_by": "Invalid value"})
|
||||
|
||||
if not ENABLE_LEARNERS_STATS.is_enabled(course_key):
|
||||
return get_users_without_stats(
|
||||
username_search_string,
|
||||
course_key,
|
||||
page,
|
||||
page_size,
|
||||
request,
|
||||
is_privileged
|
||||
)
|
||||
|
||||
params = {
|
||||
'sort_key': str(order_by),
|
||||
'page': page,
|
||||
|
||||
@@ -13,7 +13,6 @@ import ddt
|
||||
import httpretty
|
||||
import pytest
|
||||
from django.test import override_settings
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.test.client import RequestFactory
|
||||
@@ -38,7 +37,6 @@ from common.djangoapps.student.tests.factories import (
|
||||
from common.djangoapps.util.testing import UrlResetMixin
|
||||
from common.test.utils import MockSignalHandlerMixin, disable_signal
|
||||
from lms.djangoapps.discussion.django_comment_client.tests.utils import ForumsEnableMixin
|
||||
from lms.djangoapps.discussion.toggles import ENABLE_LEARNERS_TAB_IN_DISCUSSIONS_MFE
|
||||
from lms.djangoapps.discussion.rest_api import api
|
||||
from lms.djangoapps.discussion.rest_api.api import (
|
||||
create_comment,
|
||||
@@ -211,7 +209,6 @@ class GetCourseTest(ForumsEnableMixin, UrlResetMixin, SharedModuleStoreTestCase)
|
||||
'is_group_ta': False,
|
||||
'is_user_admin': False,
|
||||
'user_roles': {'Student'},
|
||||
'learners_tab_enabled': False,
|
||||
'edit_reasons': [{'code': 'test-edit-reason', 'label': 'Test Edit Reason'}],
|
||||
'post_close_reasons': [{'code': 'test-close-reason', 'label': 'Test Close Reason'}],
|
||||
}
|
||||
@@ -230,15 +227,6 @@ class GetCourseTest(ForumsEnableMixin, UrlResetMixin, SharedModuleStoreTestCase)
|
||||
assert course_meta["has_moderation_privileges"]
|
||||
assert course_meta["user_roles"] == {FORUM_ROLE_STUDENT} | {role}
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test_learner_tab_enabled_flag(self, learners_tab_enabled):
|
||||
"""
|
||||
Test the 'learners_tab_enabled' flag.
|
||||
"""
|
||||
with override_waffle_flag(ENABLE_LEARNERS_TAB_IN_DISCUSSIONS_MFE, learners_tab_enabled):
|
||||
course_meta = get_course(self.request, self.course.id)
|
||||
assert course_meta['learners_tab_enabled'] == learners_tab_enabled
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
|
||||
|
||||
@@ -21,7 +21,7 @@ from rest_framework import status
|
||||
from rest_framework.parsers import JSONParser
|
||||
from rest_framework.test import APIClient, APITestCase
|
||||
|
||||
from lms.djangoapps.discussion.config.waffle import ENABLE_LEARNERS_STATS
|
||||
from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE
|
||||
from lms.djangoapps.discussion.rest_api.utils import get_usernames_from_search_string
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -535,7 +535,6 @@ class CourseViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
|
||||
"is_group_ta": False,
|
||||
'is_user_admin': False,
|
||||
"user_roles": ["Student"],
|
||||
'learners_tab_enabled': False,
|
||||
"edit_reasons": [{"code": "test-edit-reason", "label": "Test Edit Reason"}],
|
||||
"post_close_reasons": [{"code": "test-close-reason", "label": "Test Close Reason"}],
|
||||
}
|
||||
@@ -2842,7 +2841,6 @@ class CourseDiscussionSettingsAPIViewTest(APITestCase, UrlResetMixin, ModuleStor
|
||||
'division_scheme': 'cohort',
|
||||
'available_division_schemes': ['cohort'],
|
||||
'reported_content_email_notifications': False,
|
||||
'reported_content_email_notifications_flag': False,
|
||||
}
|
||||
|
||||
def patch_request(self, data, headers=None):
|
||||
@@ -3259,7 +3257,7 @@ class CourseDiscussionRolesAPIViewTest(APITestCase, UrlResetMixin, ModuleStoreTe
|
||||
|
||||
@ddt.ddt
|
||||
@httpretty.activate
|
||||
@override_waffle_flag(ENABLE_LEARNERS_STATS, True)
|
||||
@override_waffle_flag(ENABLE_DISCUSSIONS_MFE, True)
|
||||
class CourseActivityStatsTest(ForumsEnableMixin, UrlResetMixin, CommentsServiceMockMixin, APITestCase,
|
||||
SharedModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
@@ -12,25 +12,3 @@ from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag
|
||||
# .. toggle_creation_date: 2021-11-05
|
||||
# .. toggle_target_removal_date: 2022-12-05
|
||||
ENABLE_DISCUSSIONS_MFE = CourseWaffleFlag(f'{WAFFLE_FLAG_NAMESPACE}.enable_discussions_mfe', __name__)
|
||||
|
||||
# .. toggle_name: discussions.enable_learners_tab_in_discussions_mfe
|
||||
# .. toggle_implementation: CourseWaffleFlag
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Waffle flag to enable learners tab in the new MFE experience for discussions
|
||||
# .. toggle_use_cases: temporary, open_edx
|
||||
# .. toggle_creation_date: 2022-02-21
|
||||
# .. toggle_target_removal_date: 2022-05-21
|
||||
ENABLE_LEARNERS_TAB_IN_DISCUSSIONS_MFE = CourseWaffleFlag(
|
||||
f'{WAFFLE_FLAG_NAMESPACE}.enable_learners_tab_in_discussions_mfe', __name__
|
||||
)
|
||||
|
||||
# .. toggle_name: discussions.enable_reported_content_email_notifications
|
||||
# .. toggle_implementation: CourseWaffleFlag
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Waffle flag to toggle email notifications for reported content for moderators
|
||||
# .. toggle_use_cases: temporary, open_edx
|
||||
# .. toggle_creation_date: 2022-03-08
|
||||
# .. toggle_target_removal_date: 2022-12-31
|
||||
ENABLE_REPORTED_CONTENT_EMAIL_NOTIFICATIONS = CourseWaffleFlag(
|
||||
f'{WAFFLE_FLAG_NAMESPACE}.enable_reported_content_email_notifications', __name__
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Utils for Discussions feature toggles
|
||||
"""
|
||||
from lms.djangoapps.discussion.toggles import ENABLE_REPORTED_CONTENT_EMAIL_NOTIFICATIONS
|
||||
from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE
|
||||
from openedx.core.djangoapps.django_comment_common.models import CourseDiscussionSettings
|
||||
|
||||
|
||||
@@ -10,5 +10,5 @@ def reported_content_email_notification_enabled(course_key):
|
||||
Checks for relevant flag and setting and returns boolean for reported
|
||||
content email notification for course
|
||||
"""
|
||||
return bool(ENABLE_REPORTED_CONTENT_EMAIL_NOTIFICATIONS.is_enabled(course_key) and
|
||||
return bool(ENABLE_DISCUSSIONS_MFE.is_enabled(course_key) and
|
||||
CourseDiscussionSettings.get(course_key).reported_content_email_notifications)
|
||||
|
||||
@@ -7,7 +7,6 @@ from lti_consumer.models import LtiConfiguration
|
||||
from rest_framework import serializers
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
from lms.djangoapps.discussion.toggles import ENABLE_REPORTED_CONTENT_EMAIL_NOTIFICATIONS
|
||||
from openedx.core.djangoapps.discussions.tasks import update_discussions_settings_from_course_task
|
||||
from openedx.core.djangoapps.django_comment_common.models import CourseDiscussionSettings
|
||||
from openedx.core.lib.courses import get_course_by_id
|
||||
@@ -423,8 +422,6 @@ class DiscussionSettingsSerializer(serializers.Serializer):
|
||||
'division_scheme': instance.division_scheme,
|
||||
'available_division_schemes': available_division_schemes(course_key),
|
||||
'reported_content_email_notifications': instance.reported_content_email_notifications,
|
||||
'reported_content_email_notifications_flag':
|
||||
ENABLE_REPORTED_CONTENT_EMAIL_NOTIFICATIONS.is_enabled(course_key),
|
||||
}
|
||||
return payload
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ DEFAULT_LEGACY_CONFIGURATION = {
|
||||
'division_scheme': 'none',
|
||||
'available_division_schemes': [],
|
||||
'reported_content_email_notifications': False,
|
||||
'reported_content_email_notifications_flag': False,
|
||||
}
|
||||
DEFAULT_LTI_CONFIGURATION = {
|
||||
'lti_1p1_client_key': '',
|
||||
|
||||
Reference in New Issue
Block a user