Skip to content

Commit

Permalink
chore: removed and merged multiple flags into enable_discussions_mfe …
Browse files Browse the repository at this point in the history
…flag (#33983)
  • Loading branch information
ayesha-waris authored Jan 12, 2024
1 parent 1f3d232 commit 53270f1
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 77 deletions.
1 change: 0 additions & 1 deletion cms/djangoapps/models/settings/course_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def get_exclude_list_of_fields(cls, course_key):
exclude_list.append('allow_anonymous')
exclude_list.append('allow_anonymous_to_peers')
exclude_list.append('discussion_topics')

return exclude_list

@classmethod
Expand Down
19 changes: 0 additions & 19 deletions lms/djangoapps/discussion/config/waffle.py

This file was deleted.

14 changes: 1 addition & 13 deletions lms/djangoapps/discussion/rest_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
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,
Expand Down Expand Up @@ -85,7 +85,6 @@
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,
Expand Down Expand Up @@ -365,7 +364,6 @@ def _format_datetime(dt):
"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()
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 0 additions & 12 deletions lms/djangoapps/discussion/rest_api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
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
Expand All @@ -38,7 +37,6 @@
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,
Expand Down Expand Up @@ -211,7 +209,6 @@ def test_basic(self):
'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'}],
}
Expand All @@ -230,15 +227,6 @@ def test_privileged_roles(self, role):
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})
Expand Down
6 changes: 2 additions & 4 deletions lms/djangoapps/discussion/rest_api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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
Expand Down Expand Up @@ -535,7 +535,6 @@ def test_basic(self):
"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"}],
}
Expand Down Expand Up @@ -2842,7 +2841,6 @@ def _get_expected_response(self):
'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):
Expand Down Expand Up @@ -3259,7 +3257,7 @@ def test_post_update_user_role(self, action, user_in_role):

@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):
"""
Expand Down
22 changes: 0 additions & 22 deletions lms/djangoapps/discussion/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,3 @@
# .. 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__
)
4 changes: 2 additions & 2 deletions lms/djangoapps/discussion/toggles_utils.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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)
3 changes: 0 additions & 3 deletions openedx/core/djangoapps/discussions/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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
Expand Down Expand Up @@ -423,8 +422,6 @@ def to_representation(self, instance: CourseDiscussionSettings) -> dict:
'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

Expand Down
1 change: 0 additions & 1 deletion openedx/core/djangoapps/discussions/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
'division_scheme': 'none',
'available_division_schemes': [],
'reported_content_email_notifications': False,
'reported_content_email_notifications_flag': False,
}
DEFAULT_LTI_CONFIGURATION = {
'lti_1p1_client_key': '',
Expand Down

0 comments on commit 53270f1

Please sign in to comment.