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
ccfa3ea7
Commit
ccfa3ea7
authored
Mar 03, 2017
by
rabiaiftikhar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TNl-6610 Fix "more" menu on discussion post for global staff.
parent
0c30c06a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
lms/djangoapps/django_comment_client/tests/test_utils.py
+20
-0
lms/djangoapps/django_comment_client/utils.py
+3
-2
No files found.
lms/djangoapps/django_comment_client/tests/test_utils.py
View file @
ccfa3ea7
...
...
@@ -1405,6 +1405,26 @@ class PermissionsTestCase(ModuleStoreTestCase):
'can_report'
:
True
})
def
test_get_ability_with_global_staff
(
self
):
"""
Tests that global staff has rights to report other user's post inspite
of enrolled in the course or not.
"""
content
=
{
'user_id'
:
'1'
,
'type'
:
'thread'
}
with
mock
.
patch
(
'django_comment_client.utils.check_permissions_by_view'
)
as
check_perm
:
# check_permissions_by_view returns false because user is not enrolled in the course.
check_perm
.
return_value
=
False
global_staff
=
UserFactory
(
username
=
'global_staff'
,
email
=
'global_staff@edx.org'
,
is_staff
=
True
)
self
.
assertEqual
(
utils
.
get_ability
(
None
,
content
,
global_staff
),
{
'editable'
:
False
,
'can_reply'
:
False
,
'can_delete'
:
False
,
'can_openclose'
:
False
,
'can_vote'
:
False
,
'can_report'
:
True
})
def
test_is_content_authored_by
(
self
):
content
=
{}
user
=
mock
.
Mock
()
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
ccfa3ea7
...
...
@@ -29,6 +29,7 @@ from openedx.core.djangoapps.course_groups.cohorts import (
)
from
openedx.core.djangoapps.course_groups.models
import
CourseUserGroup
from
request_cache.middleware
import
request_cached
from
student.roles
import
GlobalStaff
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -525,12 +526,12 @@ def get_ability(course_id, content, user):
content
,
"vote_for_thread"
if
content
[
'type'
]
==
'thread'
else
"vote_for_comment"
),
'can_report'
:
not
is_content_authored_by
(
content
,
user
)
and
check_permissions_by_view
(
'can_report'
:
not
is_content_authored_by
(
content
,
user
)
and
(
check_permissions_by_view
(
user
,
course_id
,
content
,
"flag_abuse_for_thread"
if
content
[
'type'
]
==
'thread'
else
"flag_abuse_for_comment"
)
)
or
GlobalStaff
()
.
has_user
(
user
))
}
# TODO: RENAME
...
...
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