diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py
index f103c74a8d..687df11f62 100644
--- a/cms/djangoapps/contentstore/utils.py
+++ b/cms/djangoapps/contentstore/utils.py
@@ -35,13 +35,13 @@ def get_course_location_for_item(location):
return location
-def get_lms_link_for_item(item):
+def get_lms_link_for_item(location):
if settings.LMS_BASE is not None:
lms_link = "{lms_base}/courses/{course_id}/jump_to/{location}".format(
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
- course_id = modulestore().get_containing_courses(item.location)[0].id,
- location=item.location,
+ course_id = modulestore().get_containing_courses(location)[0].id,
+ location=location,
)
else:
lms_link = None
diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py
index cf60de7937..43ec799a66 100644
--- a/cms/djangoapps/contentstore/views.py
+++ b/cms/djangoapps/contentstore/views.py
@@ -1,11 +1,12 @@
from util.json_request import expect_json
-import json
-import os
-import logging
-import sys
-import mimetypes
-import StringIO
import exceptions
+import json
+import logging
+import mimetypes
+import os
+import StringIO
+import sys
+import time
from collections import defaultdict
from uuid import uuid4
@@ -154,7 +155,7 @@ def edit_subsection(request, 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
if item.location.category != 'sequential':
@@ -183,7 +184,8 @@ def edit_unit(request, 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)
@@ -212,16 +214,24 @@ def edit_unit(request, location):
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', {
'unit': item,
+ 'unit_location': published_location,
'components': components,
'component_templates': component_templates,
- 'lms_link': lms_link,
+ 'draft_preview_link': lms_link,
+ 'published_preview_link': lms_link,
'subsection': containing_subsection,
'section': containing_section,
'create_new_unit_template': Location('i4x', 'edx', 'templates', 'vertical', 'Empty'),
'unit_state': unit_state,
'release_date': None,
+ 'published_date': published_date,
})
diff --git a/cms/static/sass/_unit.scss b/cms/static/sass/_unit.scss
index a030168cff..fcd2f9a64d 100644
--- a/cms/static/sass/_unit.scss
+++ b/cms/static/sass/_unit.scss
@@ -87,7 +87,7 @@
}
}
- .rendered-component {
+ .xmodule_display {
padding: 40px 20px 20px;
}
@@ -410,7 +410,8 @@
#delete-draft,
#publish-draft,
.component-actions,
- .new-component-item {
+ .new-component-item,
+ #published-alert {
display: none;
}
@@ -423,6 +424,7 @@
#save-draft,
#delete-draft,
#publish-draft,
+ #published-alert,
#create-draft, {
display: none;
}
diff --git a/cms/templates/unit.html b/cms/templates/unit.html
index 581ec0bef3..7f300d717c 100644
--- a/cms/templates/unit.html
+++ b/cms/templates/unit.html
@@ -8,14 +8,22 @@
new CMS.Views.UnitEdit({
el: $('.main-wrapper'),
model: new CMS.Models.Module({
- id: '${unit.location.url()}'
+ id: '${unit_location}'
})
});
%block>
<%block name="content">
-
+
+
+
You are editing a draft.
+ % if published_date:
+ This unit was originally published on ${published_date}.
+ % endif
+
+
Preview the published version
+
-