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.
Restyle userprofile and notifications.
- Loading branch information
1 parent
a4b475e
commit bb07fc6
Showing
17 changed files
with
324 additions
and
395 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 |
---|---|---|
@@ -1,51 +1,10 @@ | ||
# Tastypie | ||
from tastypie.resources import ModelResource | ||
from tastypie.authentication import Authentication | ||
from tastypie.authorization import Authorization | ||
|
||
|
||
class CIStaffAuthorization(Authorization): | ||
""" Limits the access to only users, who have authenticated | ||
and to CourseInstances that they are either assistants | ||
or teachers in. """ | ||
|
||
def is_authorized(self, request, object=None): | ||
return request.user.is_authenticated | ||
|
||
def apply_limits(self, request, object_list): | ||
if request.user.is_superuser: | ||
# Super users have access to all course instances | ||
return object_list | ||
else: | ||
# Other users have access to course instances they are | ||
# teachers or assistants at | ||
userprofile = request.user.userprofile | ||
return userprofile.get_courseinstance_staff_queryset.all() | ||
|
||
|
||
class SuperuserAuthorization(Authorization): | ||
|
||
def is_authorized(self, request, object=None): | ||
return request.user.is_superuser | ||
|
||
def apply_limits(self, request, object_list): | ||
return object_list | ||
|
||
|
||
class StaffAuthentication(Authentication): | ||
def is_authenticated(self, request, **kwargs): | ||
return request.user.is_staff | ||
|
||
|
||
class CourseAuthentication(Authentication): | ||
pass | ||
|
||
|
||
class CourseAuthorization(Authorization): | ||
def is_authorized(self, request, object=None): | ||
return request.user.is_authenticated | ||
|
||
def apply_limits(self, request, object_list): | ||
if request and hasattr(request, 'user'): | ||
return object_list.filter(author__username=request.user.username) | ||
return object_list.none() | ||
|
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
Oops, something went wrong.