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 51 #363

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions src/api/views/student.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ def get_permissions(self):
def get_queryset(self):
return self.request.school_teacher_user.teacher.students

def get_serializer_context(self):
serializer_context = super().get_serializer_context()
if self.action == "reset_password":
serializer_context["user_type"] = "student"

return serializer_context

def get_serializer_class(self):
if self.action == "release":
return ReleaseStudentSerializer
Expand Down
9 changes: 9 additions & 0 deletions src/api/views/student_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ def test_get_queryset__reset_password__non_admin(self):
request_method="put",
)

# test: get serializer context

def test_get_serializer_context__reset_password(self):
"""Serializer context sets user type as student."""
self.assert_get_serializer_context(
serializer_context={"user_type": "student"},
action="reset_password",
)

# test: get serializer class

def test_get_serializer_class__release(self):
Expand Down
Loading