Skip to content

Conversation

@jansenk
Copy link
Member

@jansenk jansenk commented Jan 16, 2026

Adds an endpoint LMS_BASE/api/courses/<course_id>/unified-translations/enabled that returns {'enabled': bool} to identify if the unified site translations feature is enabled or not.

Copilot AI review requested due to automatic review settings January 16, 2026 18:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a new REST API endpoint to check whether the unified site translations feature is enabled for a course. The PR also refactors the toggle from WaffleFlag to CourseWaffleFlag to support course-level overrides.

Changes:

  • Adds a new GET endpoint at /api/courses/<course_id>/unified-translations/enabled that returns {'enabled': bool}
  • Changes ENABLE_UNIFIED_SITE_AND_TRANSLATION_LANGUAGE from WaffleFlag to CourseWaffleFlag to support course-level granularity
  • Adds a helper function unified_site_and_translation_language_is_enabled() in toggles.py for consistency with other toggle checks

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lms/urls.py Registers the new endpoint URL pattern for unified translations feature status
lms/djangoapps/courseware/views/views.py Implements the view function and imports the new toggle helper
lms/djangoapps/courseware/toggles.py Updates toggle implementation to CourseWaffleFlag and adds helper function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 16, 2026 19:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3458 to +3464
@ddt.data(True, False)
def test_view(self, enabled):
course_id = 'course-v1:org+course+run'
url = reverse('unified_translations_enabled_view', args=[course_id])
with override_waffle_flag(ENABLE_UNIFIED_SITE_AND_TRANSLATION_LANGUAGE, enabled):
response = self.client.get(url)
assert response.json()['enabled'] == enabled
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test coverage is missing a test case for invalid course_id handling. There should be a test that verifies the endpoint returns an appropriate error response when provided with an invalid course identifier.

Copilot uses AI. Check for mistakes.
Comment on lines +761 to +767
urlpatterns += [
re_path(
fr'^courses/{settings.COURSE_ID_PATTERN}/unified-translations/enabled/$',
courseware_views.unified_site_and_translation_language_enabled,
name='unified_translations_enabled_view'
)
]
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new URL pattern should be grouped with the related courseware endpoints (lines 746-759) instead of being in a separate urlpatterns block. This improves code organization and maintainability by keeping related endpoints together.

Copilot uses AI. Check for mistakes.
Comment on lines +2415 to +2416
except InvalidKeyError:
return JsonResponse({"error": "Invalid course_id"})
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error response for an invalid course_id should include an appropriate HTTP status code. Currently, it returns a 200 status code by default, which is semantically incorrect for an error condition. Consider returning a 400 (Bad Request) status code to properly indicate a client error.

Copilot uses AI. Check for mistakes.
Comment on lines +3463 to +3464
response = self.client.get(url)
assert response.json()['enabled'] == enabled
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test should verify the HTTP status code of the response. The test currently only checks the response body but doesn't assert that the status code is 200, which is important for API contract validation.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants