Skip to content

Commit

Permalink
fix: unhide discussions when enabling it
Browse files Browse the repository at this point in the history
  • Loading branch information
viadanna committed Sep 11, 2024
1 parent f52c08a commit ec86ca9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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

0 comments on commit ec86ca9

Please sign in to comment.