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
482b31b9
Commit
482b31b9
authored
Jun 29, 2015
by
Syed Hassan Raza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle dates have year smaller than 1900
parent
614bcafb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
7 deletions
+22
-7
cms/djangoapps/contentstore/views/course.py
+2
-1
cms/djangoapps/contentstore/views/item.py
+14
-5
cms/djangoapps/contentstore/views/tests/test_item.py
+6
-1
No files found.
cms/djangoapps/contentstore/views/course.py
View file @
482b31b9
...
...
@@ -328,7 +328,8 @@ def _course_outline_json(request, course_module):
course_module
,
include_child_info
=
True
,
course_outline
=
True
,
include_children_predicate
=
lambda
xblock
:
not
xblock
.
category
==
'vertical'
include_children_predicate
=
lambda
xblock
:
not
xblock
.
category
==
'vertical'
,
user
=
request
.
user
)
...
...
cms/djangoapps/contentstore/views/item.py
View file @
482b31b9
...
...
@@ -479,6 +479,7 @@ def _save_xblock(user, xblock, data=None, children_strings=None, metadata=None,
if
verr
.
message
:
reason
=
_
(
"Invalid data ({details})"
)
.
format
(
details
=
verr
.
message
)
return
JsonResponse
({
"error"
:
reason
},
400
)
field
.
write_to
(
xblock
,
value
)
# update the xblock and call any xblock callbacks
...
...
@@ -754,7 +755,8 @@ def _get_module_info(xblock, rewrite_static_links=True, include_ancestor_info=Fa
def
create_xblock_info
(
xblock
,
data
=
None
,
metadata
=
None
,
include_ancestor_info
=
False
,
include_child_info
=
False
,
course_outline
=
False
,
include_children_predicate
=
NEVER
,
parent_xblock
=
None
,
graders
=
None
):
course_outline
=
False
,
include_children_predicate
=
NEVER
,
parent_xblock
=
None
,
graders
=
None
,
user
=
None
):
"""
Creates the information needed for client-side XBlockInfo.
...
...
@@ -794,6 +796,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
course_outline
,
graders
,
include_children_predicate
=
include_children_predicate
,
user
=
user
)
else
:
child_info
=
None
...
...
@@ -832,7 +835,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
"published_on"
:
get_default_time_display
(
xblock
.
published_on
)
if
published
and
xblock
.
published_on
else
None
,
"studio_url"
:
xblock_studio_url
(
xblock
,
parent_xblock
),
"released_to_students"
:
datetime
.
now
(
UTC
)
>
xblock
.
start
,
"release_date"
:
_get_release_date
(
xblock
),
"release_date"
:
_get_release_date
(
xblock
,
user
),
"visibility_state"
:
visibility_state
,
"has_explicit_staff_lock"
:
xblock
.
fields
[
'visible_to_staff_only'
]
.
is_set_on
(
xblock
),
"start"
:
xblock
.
fields
[
'start'
]
.
to_json
(
xblock
.
start
),
...
...
@@ -1003,7 +1006,7 @@ def _create_xblock_ancestor_info(xblock, course_outline):
}
def
_create_xblock_child_info
(
xblock
,
course_outline
,
graders
,
include_children_predicate
=
NEVER
):
def
_create_xblock_child_info
(
xblock
,
course_outline
,
graders
,
include_children_predicate
=
NEVER
,
user
=
None
):
"""
Returns information about the children of an xblock, as well as about the primary category
of xblock expected as children.
...
...
@@ -1021,16 +1024,22 @@ def _create_xblock_child_info(xblock, course_outline, graders, include_children_
child
,
include_child_info
=
True
,
course_outline
=
course_outline
,
include_children_predicate
=
include_children_predicate
,
parent_xblock
=
xblock
,
graders
=
graders
graders
=
graders
,
user
=
user
)
for
child
in
xblock
.
get_children
()
]
return
child_info
def
_get_release_date
(
xblock
):
def
_get_release_date
(
xblock
,
user
=
None
):
"""
Returns the release date for the xblock, or None if the release date has never been set.
"""
# If year of start date is less than 1900 then reset the start date to DEFAULT_START_DATE
if
xblock
.
start
.
year
<
1900
and
user
:
xblock
.
start
=
DEFAULT_START_DATE
xblock
=
_update_with_callback
(
xblock
,
user
)
# Treat DEFAULT_START_DATE as a magic number that means the release date has not been set
return
get_default_time_display
(
xblock
.
start
)
if
xblock
.
start
!=
DEFAULT_START_DATE
else
None
...
...
cms/djangoapps/contentstore/views/tests/test_item.py
View file @
482b31b9
...
...
@@ -29,6 +29,7 @@ from xmodule.modulestore.django import modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
TEST_DATA_SPLIT_MODULESTORE
from
xmodule.modulestore.tests.factories
import
ItemFactory
,
LibraryFactory
,
check_mongo_calls
,
CourseFactory
from
xmodule.x_module
import
STUDIO_VIEW
,
STUDENT_VIEW
from
xmodule.course_module
import
DEFAULT_START_DATE
from
xblock.exceptions
import
NoSuchHandlerError
from
xblock_django.user_service
import
DjangoXBlockUserService
from
opaque_keys.edx.keys
import
UsageKey
,
CourseKey
...
...
@@ -1531,11 +1532,14 @@ class TestXBlockInfo(ItemTest):
def
test_vertical_xblock_info
(
self
):
vertical
=
modulestore
()
.
get_item
(
self
.
vertical
.
location
)
vertical
.
start
=
datetime
(
year
=
1899
,
month
=
1
,
day
=
1
,
tzinfo
=
UTC
)
xblock_info
=
create_xblock_info
(
vertical
,
include_child_info
=
True
,
include_children_predicate
=
ALWAYS
,
include_ancestor_info
=
True
include_ancestor_info
=
True
,
user
=
self
.
user
)
add_container_page_publishing_info
(
vertical
,
xblock_info
)
self
.
validate_vertical_xblock_info
(
xblock_info
)
...
...
@@ -1601,6 +1605,7 @@ class TestXBlockInfo(ItemTest):
self
.
assertEqual
(
xblock_info
[
'display_name'
],
'Unit 1'
)
self
.
assertTrue
(
xblock_info
[
'published'
])
self
.
assertEqual
(
xblock_info
[
'edited_by'
],
'testuser'
)
self
.
assertEqual
(
xblock_info
[
'start'
],
DEFAULT_START_DATE
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
SZ'
))
# Validate that the correct ancestor info has been included
ancestor_info
=
xblock_info
.
get
(
'ancestor_info'
,
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