-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from djunicode/master
Update changes made in Upstream Repository
- Loading branch information
Showing
5 changed files
with
85 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from rest_framework.permissions import BasePermission, SAFE_METHODS | ||
|
||
# from customer.models import User | ||
|
||
|
||
class IsTPOOrOwner(BasePermission): | ||
message = "You do not have the permission to perform this action." | ||
|
||
def has_permission(self, request, view): | ||
if request.user.is_student() and view.action == "list": | ||
return False | ||
return request.user.is_authenticated | ||
|
||
def has_object_permission(self, request, view, obj): | ||
return request.user.id == obj.id or request.user.is_tpo() | ||
|
||
|
||
class IsTPOOrReadOnly(BasePermission): | ||
message = "You do not have the permission to perform this action." | ||
|
||
def has_permission(self, request, view): | ||
if view.action == "create": | ||
return request.user.is_tpo() | ||
return request.user.is_authenticated | ||
|
||
def has_object_permission(self, request, view, obj): | ||
if view.action == "retrieve": | ||
return True | ||
return request.user.is_tpo() | ||
|
||
|
||
class IsStaff(BasePermission): | ||
message = "You do not have the permission to perform this action." | ||
|
||
def has_permission(self, request, view): | ||
return request.user.is_authenticated and ( | ||
request.user.is_co() or request.user.is_tpo() | ||
) | ||
|
||
def has_object_permission(self, request, view, obj): | ||
return True |
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