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
d7f75778
Commit
d7f75778
authored
Jul 31, 2014
by
Tim Babych
Committed by
cahrens
Aug 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass parent_xblock to xblock_studio_url to avoid unnecessary calls to get_parent_xblock.
parent
5dbfd108
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
10 deletions
+9
-10
cms/djangoapps/contentstore/views/helpers.py
+7
-5
cms/djangoapps/contentstore/views/item.py
+2
-5
No files found.
cms/djangoapps/contentstore/views/helpers.py
View file @
d7f75778
...
...
@@ -55,19 +55,20 @@ def get_parent_xblock(xblock):
return
modulestore
()
.
get_item
(
parent_location
)
def
is_unit
(
xblock
):
def
is_unit
(
xblock
,
parent_xblock
=
None
):
"""
Returns true if the specified xblock is a vertical that is treated as a unit.
A unit is a vertical that is a direct child of a sequential (aka a subsection).
"""
if
xblock
.
category
==
'vertical'
:
if
parent_xblock
is
None
:
parent_xblock
=
get_parent_xblock
(
xblock
)
parent_category
=
parent_xblock
.
category
if
parent_xblock
else
None
return
parent_category
==
'sequential'
return
False
def
xblock_has_own_studio_page
(
xblock
):
def
xblock_has_own_studio_page
(
xblock
,
parent_xblock
=
None
):
"""
Returns true if the specified xblock has an associated Studio page. Most xblocks do
not have their own page but are instead shown on the page of their parent. There
...
...
@@ -80,9 +81,10 @@ def xblock_has_own_studio_page(xblock):
"""
category
=
xblock
.
category
if
is_unit
(
xblock
):
if
is_unit
(
xblock
,
parent_xblock
):
return
True
elif
category
==
'vertical'
:
if
parent_xblock
is
None
:
parent_xblock
=
get_parent_xblock
(
xblock
)
return
is_unit
(
parent_xblock
)
if
parent_xblock
else
False
...
...
@@ -90,11 +92,11 @@ def xblock_has_own_studio_page(xblock):
return
xblock
.
has_children
def
xblock_studio_url
(
xblock
):
def
xblock_studio_url
(
xblock
,
parent_xblock
=
None
):
"""
Returns the Studio editing URL for the specified xblock.
"""
if
not
xblock_has_own_studio_page
(
xblock
):
if
not
xblock_has_own_studio_page
(
xblock
,
parent_xblock
):
return
None
category
=
xblock
.
category
if
category
==
'course'
:
...
...
cms/djangoapps/contentstore/views/item.py
View file @
d7f75778
...
...
@@ -623,10 +623,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
return
None
if
parent_xblock
:
is_xblock_unit
=
parent_xblock
.
category
==
'sequential'
and
xblock
.
category
==
'vertical'
else
:
is_xblock_unit
=
is_unit
(
xblock
)
is_xblock_unit
=
is_unit
(
xblock
,
parent_xblock
)
is_unit_with_changes
=
is_xblock_unit
and
modulestore
()
.
has_changes
(
xblock
.
location
)
# Compute the child info first so it can be included in aggregate information for the parent
...
...
@@ -652,7 +649,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
"edited_on"
:
get_default_time_display
(
xblock
.
subtree_edited_on
)
if
xblock
.
subtree_edited_on
else
None
,
"published"
:
published
,
"published_on"
:
get_default_time_display
(
xblock
.
published_date
)
if
xblock
.
published_date
else
None
,
'studio_url'
:
xblock_studio_url
(
xblock
),
'studio_url'
:
xblock_studio_url
(
xblock
,
parent_xblock
),
"released_to_students"
:
datetime
.
now
(
UTC
)
>
xblock
.
start
,
"release_date"
:
release_date
,
"visibility_state"
:
_compute_visibility_state
(
xblock
,
child_info
,
is_unit_with_changes
)
if
not
xblock
.
category
==
'course'
else
None
,
...
...
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