-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: IsStudent permission class and ability to join courses (#60)
- Loading branch information
Showing
4 changed files
with
39 additions
and
14 deletions.
There are no files selected for viewing
Empty file.
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,9 @@ | ||
from rest_framework.permissions import IsAuthenticated | ||
from api.models.student import Student | ||
|
||
class IsStudent(IsAuthenticated): | ||
def has_permission(self, request, view): | ||
"""Returns true if the request contains a user, | ||
with said user being a student""" | ||
return super().has_permission(request, view) and \ | ||
Student.objects.filter(id=request.user.id).exists() |
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