Skip to content

Commit

Permalink
Portal frontend 52 (#364)
Browse files Browse the repository at this point in the history
* fix query set

* install new cfl package
  • Loading branch information
SKairinos authored Sep 25, 2024
1 parent 4df195b commit 0ae37c4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ name = "pypi"
# 5. Run `pipenv install --dev` in your terminal.

[packages]
codeforlife = {ref = "v0.18.12", git = "https://github.com/ocadotechnology/codeforlife-package-python.git"}
codeforlife = {ref = "v0.18.13", git = "https://github.com/ocadotechnology/codeforlife-package-python.git"}
# 🚫 Don't add [packages] below that are inherited from the CFL package.
pyjwt = "==2.6.0" # TODO: upgrade to latest version
# TODO: Needed by RR. Remove when RR has moved to new system.
Expand All @@ -32,7 +32,7 @@ django-sekizai = "==2.0.0"
django-classy-tags = "==2.0.0"

[dev-packages]
codeforlife = {ref = "v0.18.12", git = "https://github.com/ocadotechnology/codeforlife-package-python.git", extras = ["dev"]}
codeforlife = {ref = "v0.18.13", git = "https://github.com/ocadotechnology/codeforlife-package-python.git", extras = ["dev"]}
# codeforlife = {file = "../codeforlife-package-python", editable = true, extras = ["dev"]}
# 🚫 Don't add [dev-packages] below that are inherited from the CFL package.

Expand Down
14 changes: 7 additions & 7 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/api/views/klass.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ def get_serializer_class(self):

return ReadClassSerializer

def get_queryset(self):
if self.action in ["retrieve", "list"]:
return super().get_queryset()

teacher = self.request.school_teacher_user.teacher
return (
teacher.classes
if teacher.is_admin
else teacher.classes.filter(teacher=teacher)
)

def destroy(self, request, *args, **kwargs):
klass = self.get_object()

Expand Down
11 changes: 2 additions & 9 deletions src/api/views/klass_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ def test_get_permissions__destroy(self):
def test_get_permissions__list(self):
"""Only admin-teachers and class-teachers can list classes."""
self.assert_get_permissions(
permissions=[
OR(IsTeacher(is_admin=True), IsTeacher(in_class=True))
],
permissions=[IsTeacher(in_school=True)],
action="list",
)

Expand All @@ -96,12 +94,7 @@ def test_get_permissions__retrieve(self):
Only students, admin-teachers or class-teachers can retrieve a class.
"""
self.assert_get_permissions(
permissions=[
OR(
IsStudent(),
OR(IsTeacher(is_admin=True), IsTeacher(in_class=True)),
)
],
permissions=[OR(IsStudent(), IsTeacher(in_school=True))],
action="retrieve",
)

Expand Down

0 comments on commit 0ae37c4

Please sign in to comment.