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
1328fc5a
Commit
1328fc5a
authored
Oct 04, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store published date in module metadata, and display it on draft pages
parent
1a8532d8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
16 deletions
+40
-16
cms/djangoapps/contentstore/utils.py
+3
-3
cms/djangoapps/contentstore/views.py
+16
-6
cms/static/sass/_unit.scss
+4
-2
cms/templates/unit.html
+12
-4
common/lib/xmodule/xmodule/modulestore/draft.py
+5
-1
No files found.
cms/djangoapps/contentstore/utils.py
View file @
1328fc5a
...
@@ -35,13 +35,13 @@ def get_course_location_for_item(location):
...
@@ -35,13 +35,13 @@ def get_course_location_for_item(location):
return
location
return
location
def
get_lms_link_for_item
(
item
):
def
get_lms_link_for_item
(
location
):
if
settings
.
LMS_BASE
is
not
None
:
if
settings
.
LMS_BASE
is
not
None
:
lms_link
=
"{lms_base}/courses/{course_id}/jump_to/{location}"
.
format
(
lms_link
=
"{lms_base}/courses/{course_id}/jump_to/{location}"
.
format
(
lms_base
=
settings
.
LMS_BASE
,
lms_base
=
settings
.
LMS_BASE
,
# TODO: These will need to be changed to point to the particular instance of this problem in the particular course
# TODO: These will need to be changed to point to the particular instance of this problem in the particular course
course_id
=
modulestore
()
.
get_containing_courses
(
item
.
location
)[
0
]
.
id
,
course_id
=
modulestore
()
.
get_containing_courses
(
location
)[
0
]
.
id
,
location
=
item
.
location
,
location
=
location
,
)
)
else
:
else
:
lms_link
=
None
lms_link
=
None
...
...
cms/djangoapps/contentstore/views.py
View file @
1328fc5a
from
util.json_request
import
expect_json
from
util.json_request
import
expect_json
import
exceptions
import
json
import
json
import
os
import
logging
import
logging
import
sys
import
mimetypes
import
mimetypes
import
os
import
StringIO
import
StringIO
import
exceptions
import
sys
import
time
from
collections
import
defaultdict
from
collections
import
defaultdict
from
uuid
import
uuid4
from
uuid
import
uuid4
...
@@ -154,7 +155,7 @@ def edit_subsection(request, location):
...
@@ -154,7 +155,7 @@ def edit_subsection(request, location):
item
=
modulestore
()
.
get_item
(
location
)
item
=
modulestore
()
.
get_item
(
location
)
lms_link
=
get_lms_link_for_item
(
item
)
lms_link
=
get_lms_link_for_item
(
location
)
# make sure that location references a 'sequential', otherwise return BadRequest
# make sure that location references a 'sequential', otherwise return BadRequest
if
item
.
location
.
category
!=
'sequential'
:
if
item
.
location
.
category
!=
'sequential'
:
...
@@ -183,7 +184,8 @@ def edit_unit(request, location):
...
@@ -183,7 +184,8 @@ def edit_unit(request, location):
item
=
modulestore
()
.
get_item
(
location
)
item
=
modulestore
()
.
get_item
(
location
)
lms_link
=
get_lms_link_for_item
(
item
)
# The non-draft location
lms_link
=
get_lms_link_for_item
(
item
.
location
.
_replace
(
revision
=
None
))
component_templates
=
defaultdict
(
list
)
component_templates
=
defaultdict
(
list
)
...
@@ -212,16 +214,24 @@ def edit_unit(request, location):
...
@@ -212,16 +214,24 @@ def edit_unit(request, location):
unit_state
=
compute_unit_state
(
item
)
unit_state
=
compute_unit_state
(
item
)
try
:
published_date
=
time
.
strftime
(
'
%
B
%
d,
%
Y'
,
item
.
metadata
.
get
(
'published_date'
))
except
TypeError
:
published_date
=
None
return
render_to_response
(
'unit.html'
,
{
return
render_to_response
(
'unit.html'
,
{
'unit'
:
item
,
'unit'
:
item
,
'unit_location'
:
published_location
,
'components'
:
components
,
'components'
:
components
,
'component_templates'
:
component_templates
,
'component_templates'
:
component_templates
,
'lms_link'
:
lms_link
,
'draft_preview_link'
:
lms_link
,
'published_preview_link'
:
lms_link
,
'subsection'
:
containing_subsection
,
'subsection'
:
containing_subsection
,
'section'
:
containing_section
,
'section'
:
containing_section
,
'create_new_unit_template'
:
Location
(
'i4x'
,
'edx'
,
'templates'
,
'vertical'
,
'Empty'
),
'create_new_unit_template'
:
Location
(
'i4x'
,
'edx'
,
'templates'
,
'vertical'
,
'Empty'
),
'unit_state'
:
unit_state
,
'unit_state'
:
unit_state
,
'release_date'
:
None
,
'release_date'
:
None
,
'published_date'
:
published_date
,
})
})
...
...
cms/static/sass/_unit.scss
View file @
1328fc5a
...
@@ -87,7 +87,7 @@
...
@@ -87,7 +87,7 @@
}
}
}
}
.
rendered-component
{
.
xmodule_display
{
padding
:
40px
20px
20px
;
padding
:
40px
20px
20px
;
}
}
...
@@ -410,7 +410,8 @@
...
@@ -410,7 +410,8 @@
#delete-draft
,
#delete-draft
,
#publish-draft
,
#publish-draft
,
.component-actions
,
.component-actions
,
.new-component-item
{
.new-component-item
,
#published-alert
{
display
:
none
;
display
:
none
;
}
}
...
@@ -423,6 +424,7 @@
...
@@ -423,6 +424,7 @@
#save-draft
,
#save-draft
,
#delete-draft
,
#delete-draft
,
#publish-draft
,
#publish-draft
,
#published-alert
,
#create-draft
,
{
#create-draft
,
{
display
:
none
;
display
:
none
;
}
}
...
...
cms/templates/unit.html
View file @
1328fc5a
...
@@ -8,14 +8,22 @@
...
@@ -8,14 +8,22 @@
new
CMS
.
Views
.
UnitEdit
({
new
CMS
.
Views
.
UnitEdit
({
el
:
$
(
'.main-wrapper'
),
el
:
$
(
'.main-wrapper'
),
model
:
new
CMS
.
Models
.
Module
({
model
:
new
CMS
.
Models
.
Module
({
id
:
'${unit
.location.url()
}'
id
:
'${unit
_location
}'
})
})
});
});
</script>
</script>
</
%
block>
</
%
block>
<
%
block
name=
"content"
>
<
%
block
name=
"content"
>
<div
class=
"main-wrapper edit-state-${unit_state}"
data-id=
"${unit
.location.url()
}"
>
<div
class=
"main-wrapper edit-state-${unit_state}"
data-id=
"${unit
_location
}"
>
<div
class=
"inner-wrapper"
>
<div
class=
"inner-wrapper"
>
<div
class=
"alert"
id=
"published-alert"
>
<p
class=
"alert-message"
><strong>
You are editing a draft.
</strong>
% if published_date:
This unit was originally published on ${published_date}.
% endif
</p>
<a
href=
"${published_preview_link}"
target=
"_blank"
class=
"alert-action secondary"
>
Preview the published version
</a>
</div>
<div
class=
"main-column"
>
<div
class=
"main-column"
>
<article
class=
"unit-body window"
>
<article
class=
"unit-body window"
>
<p
class=
"unit-name-input"
><label>
Display Name:
</label><input
type=
"text"
value=
"${unit.display_name}"
class=
"unit-display-name-input"
/></p>
<p
class=
"unit-name-input"
><label>
Display Name:
</label><input
type=
"text"
value=
"${unit.display_name}"
class=
"unit-display-name-input"
/></p>
...
@@ -60,7 +68,7 @@
...
@@ -60,7 +68,7 @@
</article>
</article>
</div>
</div>
<div
class=
"sidebar
wip-box
"
>
<div
class=
"sidebar"
>
<div
class=
"unit-properties window"
>
<div
class=
"unit-properties window"
>
<h4>
Unit Properties
</h4>
<h4>
Unit Properties
</h4>
<div
class=
"window-contents"
>
<div
class=
"window-contents"
>
...
@@ -79,7 +87,7 @@
...
@@ -79,7 +87,7 @@
<div
class=
"row unit-actions"
>
<div
class=
"row unit-actions"
>
<a
id=
"save-draft"
href=
"#"
class=
"save-button"
>
Save Draft
</a>
<a
id=
"save-draft"
href=
"#"
class=
"save-button"
>
Save Draft
</a>
<a
id=
"delete-draft"
href=
"#"
class=
"save-button"
>
Delete Draft
</a>
<a
id=
"delete-draft"
href=
"#"
class=
"save-button"
>
Delete Draft
</a>
<a
href=
"${
lms
_link}"
target=
"_blank"
class=
"preview-button"
>
Preview
</a>
<a
href=
"${
draft_preview
_link}"
target=
"_blank"
class=
"preview-button"
>
Preview
</a>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
common/lib/xmodule/xmodule/modulestore/draft.py
View file @
1328fc5a
from
datetime
import
datetime
from
.
import
ModuleStoreBase
,
Location
from
.
import
ModuleStoreBase
,
Location
from
.exceptions
import
ItemNotFoundError
from
.exceptions
import
ItemNotFoundError
...
@@ -141,7 +142,10 @@ class DraftModuleStore(ModuleStoreBase):
...
@@ -141,7 +142,10 @@ class DraftModuleStore(ModuleStoreBase):
Save a current draft to the underlying modulestore
Save a current draft to the underlying modulestore
"""
"""
draft
=
self
.
get_item
(
location
)
draft
=
self
.
get_item
(
location
)
metadata
=
{}
metadata
.
update
(
draft
.
metadata
)
metadata
[
'published_date'
]
=
tuple
(
datetime
.
utcnow
()
.
timetuple
())
super
(
DraftModuleStore
,
self
)
.
update_item
(
location
,
draft
.
definition
.
get
(
'data'
,
{}))
super
(
DraftModuleStore
,
self
)
.
update_item
(
location
,
draft
.
definition
.
get
(
'data'
,
{}))
super
(
DraftModuleStore
,
self
)
.
update_children
(
location
,
draft
.
definition
.
get
(
'children'
,
[]))
super
(
DraftModuleStore
,
self
)
.
update_children
(
location
,
draft
.
definition
.
get
(
'children'
,
[]))
super
(
DraftModuleStore
,
self
)
.
update_metadata
(
location
,
draft
.
metadata
)
super
(
DraftModuleStore
,
self
)
.
update_metadata
(
location
,
metadata
)
self
.
delete_item
(
location
)
self
.
delete_item
(
location
)
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