Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
9fe6dd27
Commit
9fe6dd27
authored
Aug 18, 2015
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call super instead of referencing superclass directly.
parent
1bd4b1d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
lms/djangoapps/teams/views.py
+22
-20
No files found.
lms/djangoapps/teams/views.py
View file @
9fe6dd27
...
...
@@ -407,6 +407,28 @@ class TeamsListView(ExpandableFieldViewMixin, GenericAPIView):
return
Response
(
CourseTeamSerializer
(
team
)
.
data
)
class
IsEnrolledOrIsStaff
(
permissions
.
BasePermission
):
"""Permission that checks to see if the user is enrolled in the course or is staff."""
def
has_object_permission
(
self
,
request
,
view
,
obj
):
"""Returns true if the user is enrolled or is staff."""
return
has_team_api_access
(
request
.
user
,
obj
.
course_id
)
class
IsStaffOrPrivilegedOrReadOnly
(
IsStaffOrReadOnly
):
"""
Permission that checks to see if the user is global staff, course
staff, or has discussion privileges. If none of those conditions are
met, only read access will be granted.
"""
def
has_object_permission
(
self
,
request
,
view
,
obj
):
return
(
has_discussion_privileges
(
request
.
user
,
obj
.
course_id
)
or
super
(
IsStaffOrPrivilegedOrReadOnly
,
self
)
.
has_object_permission
(
request
,
view
,
obj
)
)
class
TeamsDetailView
(
ExpandableFieldViewMixin
,
RetrievePatchAPIView
):
"""
**Use Cases**
...
...
@@ -489,26 +511,6 @@ class TeamsDetailView(ExpandableFieldViewMixin, RetrievePatchAPIView):
method returns a 400 error with all error messages in the
"field_errors" field of the returned JSON.
"""
class
IsEnrolledOrIsStaff
(
permissions
.
BasePermission
):
"""Permission that checks to see if the user is enrolled in the course or is staff."""
def
has_object_permission
(
self
,
request
,
view
,
obj
):
"""Returns true if the user is enrolled or is staff."""
return
has_team_api_access
(
request
.
user
,
obj
.
course_id
)
class
IsStaffOrPrivilegedOrReadOnly
(
IsStaffOrReadOnly
):
"""Permission that checks to see if the user is global staff, course
staff, or has discussion privileges. If none of those conditions are
met, only read access will be granted.
"""
def
has_object_permission
(
self
,
request
,
view
,
obj
):
return
(
has_discussion_privileges
(
request
.
user
,
obj
.
course_id
)
or
IsStaffOrReadOnly
.
has_object_permission
(
self
,
request
,
view
,
obj
)
)
authentication_classes
=
(
OAuth2Authentication
,
SessionAuthentication
)
permission_classes
=
(
permissions
.
IsAuthenticated
,
IsStaffOrPrivilegedOrReadOnly
,
IsEnrolledOrIsStaff
,)
lookup_field
=
'team_id'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment