Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unhide discussion tab when enabling it (#677) #35431

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions openedx/core/djangoapps/discussions/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ def _update_course_configuration(
key not in LegacySettingsSerializer.Meta.fields_cohorts
)
}
# toogle discussion tab is_hidden
for tab in course.tabs:
if tab.tab_id == 'discussion' and tab.is_hidden == validated_data.get('enabled'):
tab.is_hidden = not validated_data.get('enabled')
save = True
break
if save:
modulestore().update_item(course, self.context['user_id'])
return instance
Expand Down
20 changes: 20 additions & 0 deletions openedx/core/djangoapps/discussions/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,26 @@ def test_add_valid_configuration(self, provider_type):
assert data['plugin_configuration'] == {'key': 'value'}
assert data['lti_configuration'] == DEFAULT_LTI_CONFIGURATION

@ddt.data(
True,
False,
)
def test_enabled_configuration(self, enabled):
"""
Test that enabling discussions unhides it.
"""
payload = {
"provider_type": Provider.PIAZZA,
"enabled": enabled,
}
self._post(payload)

data = self.get()
for tab in self.store.get_course(self.course.id).tabs:
if tab.tab_id == "discussion":
assert data["enabled"] == (not tab.is_hidden)
break

def test_change_plugin_configuration(self):
"""
Tests custom config values persist that when changing discussion
Expand Down
Loading