From 56cef9cb6a36e98ff92ea08ce139989f419c5ad6 Mon Sep 17 00:00:00 2001 From: Abdurrahman Asad <51022010+A-ASAD@users.noreply.github.com> Date: Mon, 21 Mar 2022 11:36:33 +0500 Subject: [PATCH] fix: add field to check if user is admin (#30089) fix: add field to check if user is admin --- lms/djangoapps/discussion/rest_api/api.py | 1 + lms/djangoapps/discussion/rest_api/tests/test_api.py | 1 + lms/djangoapps/discussion/rest_api/tests/test_views.py | 1 + 3 files changed, 3 insertions(+) diff --git a/lms/djangoapps/discussion/rest_api/api.py b/lms/djangoapps/discussion/rest_api/api.py index cbe509dac1..ac738f126a 100644 --- a/lms/djangoapps/discussion/rest_api/api.py +++ b/lms/djangoapps/discussion/rest_api/api.py @@ -308,6 +308,7 @@ def get_course(request, course_key): FORUM_ROLE_MODERATOR, FORUM_ROLE_COMMUNITY_TA, }), + "is_user_admin": request.user.is_staff, "provider": course_config.provider_type, "enable_in_context": course_config.enable_in_context, "group_at_subsection": course_config.plugin_configuration.get("group_at_subsection", False), diff --git a/lms/djangoapps/discussion/rest_api/tests/test_api.py b/lms/djangoapps/discussion/rest_api/tests/test_api.py index bdfcb6b318..cd8425bd28 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_api.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_api.py @@ -200,6 +200,7 @@ class GetCourseTest(ForumsEnableMixin, UrlResetMixin, SharedModuleStoreTestCase) 'group_at_subsection': False, 'provider': 'legacy', 'user_is_privileged': False, + 'is_user_admin': False, 'user_roles': {'Student'}, 'learners_tab_enabled': False, 'reason_codes_enabled': False, diff --git a/lms/djangoapps/discussion/rest_api/tests/test_views.py b/lms/djangoapps/discussion/rest_api/tests/test_views.py index e7ec8a28ef..37e97daa8f 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_views.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_views.py @@ -517,6 +517,7 @@ class CourseViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): "allow_anonymous": True, "allow_anonymous_to_peers": False, "user_is_privileged": False, + 'is_user_admin': False, "user_roles": ["Student"], 'learners_tab_enabled': False, "reason_codes_enabled": False,