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
935d5dee
Commit
935d5dee
authored
Sep 04, 2014
by
Don Mitchell
Committed by
Nimisha Asthagiri
Sep 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LMS-11331, LMS-11345 Make auth check branch agnostic; fix deserialize keys
parent
3a772752
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
cms/djangoapps/contentstore/views/access.py
+2
-1
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+14
-4
common/test/acceptance/fixtures/course.py
+5
-2
No files found.
cms/djangoapps/contentstore/views/access.py
View file @
935d5dee
...
...
@@ -20,7 +20,8 @@ def has_course_access(user, course_key, role=CourseStaffRole):
return
True
if
OrgStaffRole
(
org
=
course_key
.
org
)
.
has_user
(
user
):
return
True
return
auth
.
has_access
(
user
,
role
(
course_key
))
# temporary to ensure we give universal access given a course until we impl branch specific perms
return
auth
.
has_access
(
user
,
role
(
course_key
.
for_branch
(
None
)))
def
get_user_role
(
user
,
course_id
):
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
935d5dee
...
...
@@ -2101,7 +2101,8 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
def
_serialize_fields
(
self
,
category
,
fields
):
"""
Convert any references to their serialized form.
Convert any references to their serialized form. Handle some references already being unicoded
because the client passed them that way and nothing above this layer did the necessary deserialization.
Remove any fields which split or its kvs computes or adds but does not want persisted.
...
...
@@ -2111,17 +2112,26 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
xblock_class
=
XBlock
.
load_class
(
category
,
self
.
default_class
)
xblock_class
=
self
.
mixologist
.
mix
(
xblock_class
)
def
reference_block_id
(
reference
):
"""
Handle client possibly setting field to strings rather than keys to get the block_id
"""
# perhaps replace by fixing the views or Field Reference*.from_json to return a Key
if
isinstance
(
reference
,
basestring
):
reference
=
BlockUsageLocator
.
from_string
(
reference
)
return
BlockKey
.
from_usage_key
(
reference
)
for
field_name
,
value
in
fields
.
iteritems
():
if
value
is
not
None
:
if
isinstance
(
xblock_class
.
fields
[
field_name
],
Reference
):
fields
[
field_name
]
=
BlockKey
.
from_usage_key
(
value
)
fields
[
field_name
]
=
reference_block_id
(
value
)
elif
isinstance
(
xblock_class
.
fields
[
field_name
],
ReferenceList
):
fields
[
field_name
]
=
[
BlockKey
.
from_usage_key
(
ele
)
for
ele
in
value
reference_block_id
(
ele
)
for
ele
in
value
]
elif
isinstance
(
xblock_class
.
fields
[
field_name
],
ReferenceValueDict
):
for
key
,
subvalue
in
value
.
iteritems
():
value
[
key
]
=
BlockKey
.
from_usage_key
(
subvalue
)
value
[
key
]
=
reference_block_id
(
subvalue
)
# should this recurse down dicts and lists just in case they contain datetime?
elif
not
isinstance
(
value
,
datetime
.
datetime
):
# don't convert datetimes!
fields
[
field_name
]
=
xblock_class
.
fields
[
field_name
]
.
to_json
(
value
)
...
...
common/test/acceptance/fixtures/course.py
View file @
935d5dee
...
...
@@ -12,7 +12,6 @@ from collections import namedtuple
from
path
import
path
from
lazy
import
lazy
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.locator
import
CourseLocator
from
.
import
STUDIO_BASE_URL
...
...
@@ -272,7 +271,11 @@ class CourseFixture(StudioApiFixture):
Return the locator string for the course.
"""
course_key
=
CourseKey
.
from_string
(
self
.
_course_key
)
return
unicode
(
course_key
.
make_usage_key
(
'course'
,
self
.
_course_dict
[
'run'
]))
if
getattr
(
course_key
,
'deprecated'
,
False
):
block_id
=
self
.
_course_dict
[
'run'
]
else
:
block_id
=
'course'
return
unicode
(
course_key
.
make_usage_key
(
'course'
,
block_id
))
@property
def
_assets_url
(
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