Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portal frontend 52 #364

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

return ReadClassSerializer

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

Check warning on line 42 in src/api/views/klass.py

View check run for this annotation

Codecov / codecov/patch

src/api/views/klass.py#L42

Added line #L42 was not covered by tests

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