forked from apluslms/a-plus
-
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.
Superuser validation fixed for this version of Tastypie
- Loading branch information
Ville Vironmäki
committed
Apr 14, 2016
1 parent
57982bf
commit eb35068
Showing
2 changed files
with
14 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
from tastypie.authorization import Authorization | ||
from tastypie.exceptions import Unauthorized | ||
|
||
|
||
class SuperuserAuthorization(Authorization): | ||
|
||
|
||
# This implementation is supported only in versions 0.9.11 and below... | ||
""" | ||
def is_authorized(self, request, object=None): | ||
return request.user.is_superuser | ||
def apply_limits(self, request, object_list): | ||
return object_list | ||
return object_list""" | ||
|
||
# Implementation in versions 0.9.12 and up. | ||
def read_list(self, object_list, bundle): | ||
# Is the person who made the request, superuser? | ||
if bundle.request.user.is_superuser: | ||
return object_list | ||
else: | ||
raise Unauthorized("Sorry, only VIP.") |
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