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
11b709af
Commit
11b709af
authored
Mar 24, 2016
by
Usman Khalid
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11930 from edx/private/release
Merge private/release into release
parents
8f8ed776
59b452a4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
96 additions
and
12 deletions
+96
-12
cms/djangoapps/contentstore/tests/test_course_settings.py
+20
-3
cms/djangoapps/contentstore/tests/test_utils.py
+1
-1
cms/envs/bok_choy.env.json
+1
-1
cms/envs/test.py
+2
-1
lms/djangoapps/courseware/access.py
+54
-1
lms/djangoapps/courseware/access_utils.py
+2
-1
lms/djangoapps/courseware/tests/test_access.py
+0
-0
lms/envs/aws.py
+7
-0
lms/envs/bok_choy.env.json
+1
-1
lms/envs/common.py
+0
-3
lms/envs/test.py
+8
-0
No files found.
cms/djangoapps/contentstore/tests/test_course_settings.py
View file @
11b709af
...
...
@@ -6,7 +6,7 @@ import ddt
import
json
import
copy
import
mock
from
mock
import
patch
from
mock
import
Mock
,
patch
import
unittest
from
django.conf
import
settings
...
...
@@ -19,7 +19,7 @@ from models.settings.course_metadata import CourseMetadata
from
models.settings.encoder
import
CourseSettingsEncoder
from
openedx.core.djangoapps.self_paced.models
import
SelfPacedConfiguration
from
openedx.core.djangoapps.models.course_details
import
CourseDetails
from
student.roles
import
CourseInstructorRole
from
student.roles
import
CourseInstructorRole
,
CourseStaffRole
from
student.tests.factories
import
UserFactory
from
xmodule.fields
import
Date
from
xmodule.modulestore
import
ModuleStoreEnum
...
...
@@ -28,7 +28,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
from
xmodule.tabs
import
InvalidTabsException
from
milestones.tests.utils
import
MilestonesTestCaseMixin
from
.utils
import
CourseTestCase
from
.utils
import
CourseTestCase
,
AjaxEnabledTestClient
def
get_url
(
course_id
,
handler_name
=
'settings_handler'
):
...
...
@@ -949,6 +949,23 @@ class CourseMetadataEditingTest(CourseTestCase):
tab_list
.
append
(
self
.
notes_tab
)
self
.
assertEqual
(
tab_list
,
course
.
tabs
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_EDXNOTES'
:
True
})
@patch
(
'xmodule.util.django.get_current_request'
)
def
test_post_settings_with_staff_not_enrolled
(
self
,
mock_request
):
"""
Tests that we can post advance settings when course staff is not enrolled.
"""
mock_request
.
return_value
=
Mock
(
META
=
{
'HTTP_HOST'
:
'localhost'
})
user
=
UserFactory
.
create
(
is_staff
=
True
)
CourseStaffRole
(
self
.
course
.
id
)
.
add_users
(
user
)
client
=
AjaxEnabledTestClient
()
client
.
login
(
username
=
user
.
username
,
password
=
user
.
password
)
response
=
self
.
client
.
ajax_post
(
self
.
course_setting_url
,
{
'advanced_modules'
:
{
"value"
:
[
""
]}
})
self
.
assertEqual
(
response
.
status_code
,
200
)
class
CourseGraderUpdatesTest
(
CourseTestCase
):
"""
...
...
cms/djangoapps/contentstore/tests/test_utils.py
View file @
11b709af
...
...
@@ -79,7 +79,7 @@ class LMSLinksTestCase(TestCase):
link
=
utils
.
get_lms_link_for_item
(
location
,
True
)
self
.
assertEquals
(
link
,
"//preview/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us"
"//preview
.localhost
/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us"
)
# now test with the course' location
...
...
cms/envs/bok_choy.env.json
View file @
11b709af
...
...
@@ -73,7 +73,7 @@
"ENABLE_S3_GRADE_DOWNLOADS"
:
true
,
"ENTRANCE_EXAMS"
:
true
,
"MILESTONES_APP"
:
true
,
"PREVIEW_LMS_BASE"
:
"localhost:8003"
,
"PREVIEW_LMS_BASE"
:
"
preview.
localhost:8003"
,
"ALLOW_ALL_ADVANCED_COMPONENTS"
:
true
,
"ENABLE_CONTENT_LIBRARIES"
:
true
,
"ENABLE_SPECIAL_EXAMS"
:
true
,
...
...
cms/envs/test.py
View file @
11b709af
...
...
@@ -136,7 +136,8 @@ if os.environ.get('DISABLE_MIGRATIONS'):
MIGRATION_MODULES
=
NoOpMigrationModules
()
LMS_BASE
=
"localhost:8000"
FEATURES
[
'PREVIEW_LMS_BASE'
]
=
"preview"
FEATURES
[
'PREVIEW_LMS_BASE'
]
=
"preview.localhost"
CACHES
=
{
# This is the cache used for most things. Askbot will not work without a
...
...
lms/djangoapps/courseware/access.py
View file @
11b709af
...
...
@@ -61,7 +61,10 @@ from courseware.access_response import (
MobileAvailabilityError
,
VisibilityError
,
)
from
courseware.access_utils
import
adjust_start_date
,
check_start_date
,
debug
,
ACCESS_GRANTED
,
ACCESS_DENIED
from
courseware.access_utils
import
(
adjust_start_date
,
check_start_date
,
debug
,
ACCESS_GRANTED
,
ACCESS_DENIED
,
in_preview_mode
)
from
lms.djangoapps.ccx.custom_exception
import
CCXLocatorValidationException
from
lms.djangoapps.ccx.models
import
CustomCourseForEdX
...
...
@@ -135,6 +138,10 @@ def has_access(user, action, obj, course_key=None):
if
isinstance
(
course_key
,
CCXLocator
):
course_key
=
course_key
.
to_course_locator
()
if
in_preview_mode
():
if
not
bool
(
has_staff_access_to_preview_mode
(
user
=
user
,
obj
=
obj
,
course_key
=
course_key
)):
return
ACCESS_DENIED
# delegate the work to type-specific functions.
# (start with more specific types, then get more general)
if
isinstance
(
obj
,
CourseDescriptor
):
...
...
@@ -172,6 +179,52 @@ def has_access(user, action, obj, course_key=None):
# ================ Implementation helpers ================================
def
has_staff_access_to_preview_mode
(
user
,
obj
,
course_key
=
None
):
"""
Returns whether user has staff access to specified modules or not.
Arguments:
user: a Django user object.
obj: The object to check access for.
course_key: A course_key specifying which course this access is for.
Returns an AccessResponse object.
"""
if
course_key
is
None
:
if
isinstance
(
obj
,
CourseDescriptor
)
or
isinstance
(
obj
,
CourseOverview
):
course_key
=
obj
.
id
elif
isinstance
(
obj
,
ErrorDescriptor
):
course_key
=
obj
.
location
.
course_key
elif
isinstance
(
obj
,
XModule
):
course_key
=
obj
.
descriptor
.
course_key
elif
isinstance
(
obj
,
XBlock
):
course_key
=
obj
.
location
.
course_key
elif
isinstance
(
obj
,
CCXLocator
):
course_key
=
obj
.
to_course_locator
()
elif
isinstance
(
obj
,
CourseKey
):
course_key
=
obj
elif
isinstance
(
obj
,
UsageKey
):
course_key
=
obj
.
course_key
if
course_key
is
None
:
if
GlobalStaff
()
.
has_user
(
user
):
return
ACCESS_GRANTED
else
:
return
ACCESS_DENIED
return
_has_access_to_course
(
user
,
'staff'
,
course_key
=
course_key
)
def
_can_access_descriptor_with_start_date
(
user
,
descriptor
,
course_key
):
# pylint: disable=invalid-name
"""
Checks if a user has access to a descriptor based on its start date.
...
...
lms/djangoapps/courseware/access_utils.py
View file @
11b709af
...
...
@@ -78,4 +78,5 @@ def in_preview_mode():
Returns whether the user is in preview mode or not.
"""
hostname
=
get_current_request_hostname
()
return
bool
(
hostname
and
settings
.
PREVIEW_DOMAIN
in
hostname
.
split
(
'.'
))
preview_lms_base
=
settings
.
FEATURES
.
get
(
'PREVIEW_LMS_BASE'
,
None
)
return
bool
(
preview_lms_base
and
hostname
and
hostname
.
split
(
':'
)[
0
]
==
preview_lms_base
.
split
(
':'
)[
0
])
lms/djangoapps/courseware/tests/test_access.py
View file @
11b709af
This diff is collapsed.
Click to expand it.
lms/envs/aws.py
View file @
11b709af
...
...
@@ -405,6 +405,13 @@ if 'DJFS' in AUTH_TOKENS and AUTH_TOKENS['DJFS'] is not None:
############### Module Store Items ##########
HOSTNAME_MODULESTORE_DEFAULT_MAPPINGS
=
ENV_TOKENS
.
get
(
'HOSTNAME_MODULESTORE_DEFAULT_MAPPINGS'
,
{})
# PREVIEW DOMAIN must be present in HOSTNAME_MODULESTORE_DEFAULT_MAPPINGS for the preview to show draft changes
if
'PREVIEW_LMS_BASE'
in
FEATURES
and
FEATURES
[
'PREVIEW_LMS_BASE'
]
!=
''
:
PREVIEW_DOMAIN
=
FEATURES
[
'PREVIEW_LMS_BASE'
]
.
split
(
':'
)[
0
]
# update dictionary with preview domain regex
HOSTNAME_MODULESTORE_DEFAULT_MAPPINGS
.
update
({
PREVIEW_DOMAIN
:
'draft-preferred'
})
############### Mixed Related(Secure/Not-Secure) Items ##########
LMS_SEGMENT_KEY
=
AUTH_TOKENS
.
get
(
'SEGMENT_KEY'
)
...
...
lms/envs/bok_choy.env.json
View file @
11b709af
...
...
@@ -81,7 +81,7 @@
"ENABLE_S3_GRADE_DOWNLOADS"
:
true
,
"ENABLE_THIRD_PARTY_AUTH"
:
true
,
"ENABLE_COMBINED_LOGIN_REGISTRATION"
:
true
,
"PREVIEW_LMS_BASE"
:
"localhost:8003"
,
"PREVIEW_LMS_BASE"
:
"
preview.
localhost:8003"
,
"ALLOW_AUTOMATED_SIGNUPS"
:
true
,
"AUTOMATIC_AUTH_FOR_TESTING"
:
true
,
"MODE_CREATION_FOR_TESTING"
:
true
,
...
...
lms/envs/common.py
View file @
11b709af
...
...
@@ -2667,9 +2667,6 @@ PROFILE_IMAGE_SECRET_KEY = 'placeholder secret key'
PROFILE_IMAGE_MAX_BYTES
=
1024
*
1024
PROFILE_IMAGE_MIN_BYTES
=
100
# This is to check the domain in case of preview.
PREVIEW_DOMAIN
=
'preview'
# Sets the maximum number of courses listed on the homepage
# If set to None, all courses will be listed on the homepage
HOMEPAGE_COURSE_MAX
=
None
...
...
lms/envs/test.py
View file @
11b709af
...
...
@@ -394,6 +394,14 @@ YOUTUBE_PORT = 8031
LTI_PORT
=
8765
VIDEO_SOURCE_PORT
=
8777
FEATURES
[
'PREVIEW_LMS_BASE'
]
=
"preview.localhost"
############### Module Store Items ##########
PREVIEW_DOMAIN
=
FEATURES
[
'PREVIEW_LMS_BASE'
]
.
split
(
':'
)[
0
]
HOSTNAME_MODULESTORE_DEFAULT_MAPPINGS
=
{
PREVIEW_DOMAIN
:
'draft-preferred'
}
################### Make tests faster
#http://slacy.com/blog/2012/04/make-your-tests-faster-in-django-1-4/
...
...
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