Skip to content
Merged
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
8 changes: 8 additions & 0 deletions openedx/core/djangoapps/discussions/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ def _update_course_configuration(
key not in LegacySettingsSerializer.Meta.fields_cohorts
)
}
# Toggle discussion tab is_hidden. Before Palm, we would mark the discussion tab with the is_hidden property.
# Redwood and later, we disable discussions entirely by toggling the discussion configuration enabled property.
# This ensures pre-Palm courses import with discussions tab appropriately shown/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 setting the "enabled" property for Discussions shows the Discussions tab.
"""
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