generated from ocadotechnology/codeforlife-template-backend
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* sync submodules * configure codecov * include current and exclude coverage files * fix pipeline * fix base user serializer tests * fix return type * update coverage settings * add missing tests * omit main and manage * partially refactored * fix and test school teacher invitations * new cfl package * reuse create teacher serializer * fix lint error * add additional tests
- Loading branch information
Showing
21 changed files
with
1,046 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,8 +36,22 @@ | |
"from_teacher": 7, | ||
"invited_teacher_first_name": "Invited", | ||
"invited_teacher_last_name": "Teacher", | ||
"invited_teacher_email": "[email protected]", | ||
"invited_teacher_is_admin": false, | ||
"invited_teacher_email": "[email protected]", | ||
"invited_teacher_is_admin": true, | ||
"expiry": "9999-02-09 20:26:08.298402+00:00" | ||
} | ||
}, | ||
{ | ||
"model": "common.schoolteacherinvitation", | ||
"pk": 4, | ||
"fields": { | ||
"token": "pbkdf2_sha256$260000$hbsAadmrRo744BTM6NofUb$ePs/7vi6sSzOPpiWxNhXMZnNnE7aXOpzIhxrAa/rdiU=", | ||
"school": 2, | ||
"from_teacher": 7, | ||
"invited_teacher_first_name": "Invited", | ||
"invited_teacher_last_name": "Independent", | ||
"invited_teacher_email": "[email protected]", | ||
"invited_teacher_is_admin": true, | ||
"expiry": "9999-02-09 20:26:08.298402+00:00" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[ | ||
{ | ||
"model": "common.schoolteacherinvitation", | ||
"pk": 5, | ||
"fields": { | ||
"token": "pbkdf2_sha256$260000$hbsAadmrRo744BTM6NofUb$ePs/7vi6sSzOPpiWxNhXMZnNnE7aXOpzIhxrAa/rdiU=", | ||
"school": 3, | ||
"from_teacher": 8, | ||
"invited_teacher_first_name": "Invited", | ||
"invited_teacher_last_name": "Teacher", | ||
"invited_teacher_email": "[email protected]", | ||
"invited_teacher_is_admin": false, | ||
"expiry": "9999-02-09 20:26:08.298402+00:00" | ||
} | ||
}, | ||
{ | ||
"model": "common.schoolteacherinvitation", | ||
"pk": 6, | ||
"fields": { | ||
"token": "pbkdf2_sha256$260000$hbsAadmrRo744BTM6NofUb$ePs/7vi6sSzOPpiWxNhXMZnNnE7aXOpzIhxrAa/rdiU=", | ||
"school": 3, | ||
"from_teacher": 8, | ||
"invited_teacher_first_name": "Invited", | ||
"invited_teacher_last_name": "Teacher", | ||
"invited_teacher_email": "[email protected]", | ||
"invited_teacher_is_admin": false, | ||
"expiry": "9999-02-09 20:26:08.298402+00:00" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
""" | ||
© Ocado Group | ||
Created on 24/04/2024 at 11:57:02(+01:00). | ||
""" | ||
|
||
from .is_invited_school_teacher import IsInvitedSchoolTeacher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
© Ocado Group | ||
Created on 24/04/2024 at 11:57:38(+01:00). | ||
""" | ||
|
||
import typing as t | ||
|
||
from codeforlife.permissions import BasePermission | ||
from django.contrib.auth.hashers import check_password | ||
from rest_framework.viewsets import ModelViewSet | ||
|
||
from ..models import SchoolTeacherInvitation | ||
|
||
|
||
class IsInvitedSchoolTeacher(BasePermission): | ||
"""The request is being made by the teacher invited to join a school.""" | ||
|
||
def has_permission( # type: ignore[override] | ||
self, request, view: ModelViewSet | ||
): | ||
pk: t.Optional[str] = view.kwargs.get( | ||
view.lookup_url_kwarg or view.lookup_field | ||
) | ||
|
||
token: t.Optional[str] = request.data.get("token") | ||
|
||
if pk is not None and token is not None: | ||
invitation = SchoolTeacherInvitation.objects.get(pk=int(pk)) | ||
|
||
return check_password(token, invitation.token) | ||
|
||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.