Skip to content

Commit

Permalink
fix: do not show legacy in case openedx discussion provider is select…
Browse files Browse the repository at this point in the history
…ed (#33906)

* fix: do not show legacy in case openedx discussion provider is selected
  • Loading branch information
AhtishamShahid authored Dec 19, 2023
1 parent 2eac2ef commit c287e0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 7 additions & 5 deletions openedx/core/djangoapps/discussions/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,14 @@ class ProviderDataTest(CourseInstructorAuthorizedTest, DataTestMixin):
# If the legacy provider is selected always show the legacy provider,
# and only show the new one if the toggle is enabled
(Provider.LEGACY, [Provider.LEGACY], Provider.OPEN_EDX, False),
(Provider.LEGACY, [Provider.LEGACY, Provider.OPEN_EDX], 'dummy', True),
(Provider.LEGACY, [Provider.LEGACY], 'dummy', True),
# If the new provider is selected show the legacy provider only
# if the new discussions toggle is disabled
(Provider.OPEN_EDX, [Provider.OPEN_EDX, Provider.LEGACY], 'dummy', False),
(Provider.OPEN_EDX, [Provider.OPEN_EDX], 'dummy', False),
(Provider.OPEN_EDX, [Provider.OPEN_EDX], Provider.LEGACY, True),
# If some other provider is selected show only legacy provider if the toggle is false
# and only the new provider if the toggle is enabled
(Provider.PIAZZA, [Provider.LEGACY], Provider.OPEN_EDX, False),
(Provider.PIAZZA, [], Provider.OPEN_EDX, False),
(Provider.PIAZZA, [Provider.OPEN_EDX], Provider.LEGACY, True),
)
@ddt.unpack
Expand Down Expand Up @@ -424,9 +424,11 @@ def test_available_providers_staff(self, current_provider, new_structure_enabled
with override_waffle_flag(ENABLE_NEW_STRUCTURE_DISCUSSIONS, new_structure_enabled):
response = self._get()
data = response.json()
visible_providers = [Provider.OPEN_EDX, Provider.LEGACY]
if not new_structure_enabled:
visible_providers = []
if current_provider == Provider.LEGACY:
visible_providers = [Provider.LEGACY]
if current_provider != Provider.LEGACY and new_structure_enabled:
visible_providers = [Provider.OPEN_EDX]
for visible_provider in visible_providers:
assert visible_provider in data['providers']['available'].keys()

Expand Down
7 changes: 6 additions & 1 deletion openedx/core/djangoapps/discussions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get(self, request, course_key_string: str, **_kwargs) -> Response:
Handle HTTP/GET requests
"""
# Return all providers always, if the user is staff
data = self.get_provider_data(course_key_string, show_all=request.user.is_staff)
data = self.get_provider_data(course_key_string, show_all=False)
return Response(data)

@staticmethod
Expand Down Expand Up @@ -189,6 +189,11 @@ def get_provider_data(course_key_string: str, show_all: bool = False) -> Dict:
if configuration.provider_type != Provider.OPEN_EDX:
hidden_providers.append(Provider.OPEN_EDX)

if configuration.provider_type != Provider.LEGACY:
hidden_providers.append(Provider.LEGACY)
else:
hidden_providers.append(Provider.OPEN_EDX)

serializer = DiscussionsProvidersSerializer(
{
'features': [
Expand Down

0 comments on commit c287e0a

Please sign in to comment.