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
660cdf79
Commit
660cdf79
authored
Sep 11, 2014
by
Usman Khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added instructor persmission to _has_access_error_desc() in courseware.access.
TNL-208
parent
f1da4efb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
lms/djangoapps/courseware/access.py
+2
-1
lms/djangoapps/courseware/tests/test_access.py
+22
-5
No files found.
lms/djangoapps/courseware/access.py
View file @
660cdf79
...
...
@@ -230,7 +230,8 @@ def _has_access_error_desc(user, action, descriptor, course_key):
checkers
=
{
'load'
:
check_for_staff
,
'staff'
:
check_for_staff
'staff'
:
check_for_staff
,
'instructor'
:
lambda
:
_has_instructor_access_to_descriptor
(
user
,
descriptor
,
course_key
)
}
return
_dispatch
(
checkers
,
action
,
user
,
descriptor
)
...
...
lms/djangoapps/courseware/tests/test_access.py
View file @
660cdf79
...
...
@@ -83,17 +83,34 @@ class AccessTestCase(TestCase):
self
.
assertRaises
(
ValueError
,
access
.
_has_access_string
,
user
,
'not_staff'
,
'global'
,
self
.
course
.
course_key
)
def
test__has_access_error_desc
(
self
):
descriptor
=
Mock
()
self
.
assertFalse
(
access
.
_has_access_error_desc
(
self
.
student
,
'load'
,
descriptor
,
self
.
course
.
course_key
))
self
.
assertTrue
(
access
.
_has_access_error_desc
(
self
.
course_staff
,
'load'
,
descriptor
,
self
.
course
.
course_key
))
self
.
assertTrue
(
access
.
_has_access_error_desc
(
self
.
course_instructor
,
'load'
,
descriptor
,
self
.
course
.
course_key
))
self
.
assertFalse
(
access
.
_has_access_error_desc
(
self
.
student
,
'staff'
,
descriptor
,
self
.
course
.
course_key
))
self
.
assertTrue
(
access
.
_has_access_error_desc
(
self
.
course_staff
,
'staff'
,
descriptor
,
self
.
course
.
course_key
))
self
.
assertTrue
(
access
.
_has_access_error_desc
(
self
.
course_instructor
,
'staff'
,
descriptor
,
self
.
course
.
course_key
))
self
.
assertFalse
(
access
.
_has_access_error_desc
(
self
.
student
,
'instructor'
,
descriptor
,
self
.
course
.
course_key
))
self
.
assertFalse
(
access
.
_has_access_error_desc
(
self
.
course_staff
,
'instructor'
,
descriptor
,
self
.
course
.
course_key
))
self
.
assertTrue
(
access
.
_has_access_error_desc
(
self
.
course_instructor
,
'instructor'
,
descriptor
,
self
.
course
.
course_key
))
with
self
.
assertRaises
(
ValueError
):
access
.
_has_access_error_desc
(
self
.
course_instructor
,
'not_load_or_staff'
,
descriptor
,
self
.
course
.
course_key
)
def
test__has_access_descriptor
(
self
):
# TODO: override DISABLE_START_DATES and test the start date branch of the method
user
=
Mock
()
date
=
Mock
()
date
.
start
=
datetime
.
datetime
.
now
(
pytz
.
utc
)
-
datetime
.
timedelta
(
days
=
1
)
# make sure the start time is in the past
descriptor
=
Mock
()
# Always returns true because DISABLE_START_DATES is set in test.py
self
.
assertTrue
(
access
.
_has_access_descriptor
(
user
,
'load'
,
d
ate
))
self
.
assertTrue
(
access
.
_has_access_descriptor
(
user
,
'instructor'
,
d
ate
))
self
.
assertTrue
(
access
.
_has_access_descriptor
(
user
,
'load'
,
d
escriptor
))
self
.
assertTrue
(
access
.
_has_access_descriptor
(
user
,
'instructor'
,
d
escriptor
))
with
self
.
assertRaises
(
ValueError
):
access
.
_has_access_descriptor
(
user
,
'not_load_or_staff'
,
d
ate
)
access
.
_has_access_descriptor
(
user
,
'not_load_or_staff'
,
d
escriptor
)
@mock.patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test__has_access_descriptor_staff_lock
(
self
):
...
...
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