From 3381de64d1755ced87172c3920b599a55593e8f8 Mon Sep 17 00:00:00 2001 From: Johan Seto Kaiba <51926076+johanseto@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:36:48 -0500 Subject: [PATCH] feat: remove staff access in courses for catalog views (#37) * feat: remove staff access for catalog views This is controversial, but simple. To do this in a monkey patch is a bigger task and also with more work. Is different due the change is in a nested function. Anyway the alternative is to monkeyPatch the _dispatch method and handle there. But its risky and also that method manage other permission with different ways. * feat: keep custom test with default behavior To use you configure the setting: `STAFF_CAN_SEE_IN_CATALOG` --- lms/djangoapps/courseware/access.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/access.py b/lms/djangoapps/courseware/access.py index f71f2daec5bb..de92d3895ffb 100644 --- a/lms/djangoapps/courseware/access.py +++ b/lms/djangoapps/courseware/access.py @@ -394,7 +394,10 @@ def can_see_in_catalog(): """ return ( _has_catalog_visibility(courselike, CATALOG_VISIBILITY_CATALOG_AND_ABOUT) - or _has_staff_access_to_descriptor(user, courselike, courselike.id) + or ( + _has_staff_access_to_descriptor(user, courselike, courselike.id) + and getattr(settings, "STAFF_CAN_SEE_IN_CATALOG", True) + ) ) @function_trace('can_see_about_page')