Skip to content

Commit a2ce13f

Browse files
committed
change problem set list permissions
1 parent 6fac716 commit a2ce13f

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

learning_resources/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ def has_permission(self, request, view): # noqa: ARG002
14001400
return True
14011401
return user.groups.filter(name=GROUP_TUTOR_PROBLEM_VIEWERS).exists()
14021402

1403-
permission_classes = (IsAdminOrTutorProblemViewer,)
1403+
permission_classes = ()
14041404

14051405
http_method_names = ["get"]
14061406
lookup_field = "run_readable_id"
@@ -1410,6 +1410,7 @@ def has_permission(self, request, view): # noqa: ARG002
14101410
detail=False,
14111411
methods=["get"],
14121412
url_path=r"(?P<run_readable_id>[^/]+)",
1413+
permission_classes=[AnonymousAccessReadonlyPermission],
14131414
)
14141415
def list_problems(self, request, run_readable_id): # noqa: ARG002
14151416
"""
@@ -1434,6 +1435,7 @@ def list_problems(self, request, run_readable_id): # noqa: ARG002
14341435
detail=False,
14351436
methods=["get"],
14361437
url_path=r"(?P<run_readable_id>[^/]+)/(?P<problem_title>[^/]+)",
1438+
permission_classes=[IsAdminOrTutorProblemViewer],
14371439
)
14381440
def retrieve_problem(self, request, run_readable_id, problem_title): # noqa: ARG002
14391441
run = LearningResourceRun.objects.filter(

learning_resources/views_test.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,20 +1463,7 @@ def test_course_run_problems_endpoint(client, user_role, django_user_model):
14631463
reverse("lr:v0:tutorproblem_api-list-problems", args=[course_run.run_id])
14641464
)
14651465

1466-
if user_role in ["admin", "group_tutor_problem_viewer"]:
1467-
assert resp.json() == {"problem_set_titles": ["Problem Set 1", "Problem Set 2"]}
1468-
elif user_role == "normal":
1469-
assert resp.status_code == 403
1470-
assert resp.json() == {
1471-
"detail": "You do not have permission to perform this action.",
1472-
"error_type": "PermissionDenied",
1473-
}
1474-
elif user_role == "anonymous":
1475-
assert resp.status_code == 403
1476-
assert resp.json() == {
1477-
"detail": "Authentication credentials were not provided.",
1478-
"error_type": "NotAuthenticated",
1479-
}
1466+
assert resp.json() == {"problem_set_titles": ["Problem Set 1", "Problem Set 2"]}
14801467

14811468
detail_resp = client.get(
14821469
reverse(

0 commit comments

Comments
 (0)