Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
9fe6dd27
Commit
9fe6dd27
authored
9 years ago
by
cahrens
Browse files
Options
Downloads
Patches
Plain Diff
Call super instead of referencing superclass directly.
parent
1bd4b1d6
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lms/djangoapps/teams/views.py
+22
-20
22 additions, 20 deletions
lms/djangoapps/teams/views.py
with
22 additions
and
20 deletions
lms/djangoapps/teams/views.py
+
22
−
20
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
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment