Skip to content

Commit 16f8063

Browse files
committed
fixup! fix: adjust studio_grading_url to use the correct URL
1 parent 5592ba4 commit 16f8063

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

lms/djangoapps/instructor/tests/test_api_v2.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ def test_get_course_metadata_as_instructor(self):
180180
assert data['studio_grading_url'] == f'http://localhost:2001/authoring/course/{self.course.id}/settings/grading'
181181
assert data['admin_console_url'] == 'http://localhost:2025/admin-console/authz'
182182

183+
def test_admin_console_url_requires_instructor_access(self):
184+
"""
185+
Test that the admin console URL is only available to users with instructor access.
186+
"""
187+
# data researcher has access to course but is not an instructor
188+
self.client.force_authenticate(user=self.data_researcher)
189+
response = self.client.get(self._get_url())
190+
191+
assert response.status_code == status.HTTP_200_OK
192+
assert 'admin_console_url' in response.data
193+
data = response.data
194+
assert data['admin_console_url'] is None
195+
183196
def test_get_course_metadata_as_staff(self):
184197
"""
185198
Test that course staff can retrieve course metadata.

lms/djangoapps/instructor/views/serializers_v2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class CourseInformationSerializerV2(serializers.Serializer):
7676
help_text="URL to the Studio grading settings page for the course (null if not configured)"
7777
)
7878
admin_console_url = serializers.SerializerMethodField(
79-
help_text="URL to the admin console"
79+
help_text="URL to the admin console (requires instructor access and MFE configuration, null if not accessible)"
8080
)
8181
permissions = serializers.SerializerMethodField(help_text="User permissions for instructor dashboard features")
8282
tabs = serializers.SerializerMethodField(help_text="List of course tabs with configuration and display information")
@@ -469,7 +469,7 @@ def get_studio_grading_url(self, data):
469469
return f'{mfe_base_url}/course/{course_key}/settings/grading'
470470

471471
def get_admin_console_url(self, data):
472-
"""Get admin console URL."""
472+
"""Get admin console URL (requires instructor access and MFE configuration, null if not accessible)."""
473473
course_key = data['course'].id
474474
request = data['request']
475475
has_instructor_access = has_access(request.user, 'instructor', data['course'])
@@ -480,7 +480,6 @@ def get_admin_console_url(self, data):
480480
)
481481
if not mfe_base_url or not has_instructor_access:
482482
return None
483-
484483
return f'{mfe_base_url}/authz'
485484

486485
def get_disable_buttons(self, data):

0 commit comments

Comments
 (0)