Commit 85fa712f by Don Mitchell

Change published_date to published_on

to make consistent with other edit info timestamps
LMS-11184
parent 4878f6e8
...@@ -666,7 +666,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F ...@@ -666,7 +666,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
"category": xblock.category, "category": xblock.category,
"edited_on": get_default_time_display(xblock.subtree_edited_on) if xblock.subtree_edited_on else None, "edited_on": get_default_time_display(xblock.subtree_edited_on) if xblock.subtree_edited_on else None,
"published": published, "published": published,
"published_on": get_default_time_display(xblock.published_date) if xblock.published_date else None, "published_on": get_default_time_display(xblock.published_on) if xblock.published_on else None,
"studio_url": xblock_studio_url(xblock, parent_xblock), "studio_url": xblock_studio_url(xblock, parent_xblock),
"released_to_students": datetime.now(UTC) > xblock.start, "released_to_students": datetime.now(UTC) > xblock.start,
"release_date": release_date, "release_date": release_date,
......
...@@ -235,14 +235,14 @@ class CachingDescriptorSystem(MakoDescriptorSystem): ...@@ -235,14 +235,14 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
edit_info = json_data.get('edit_info') edit_info = json_data.get('edit_info')
# migrate published_by and published_date if edit_info isn't present # migrate published_by and published_on if edit_info isn't present
if not edit_info: if not edit_info:
module.edited_by = module.edited_on = module.subtree_edited_on = \ module.edited_by = module.edited_on = module.subtree_edited_on = \
module.subtree_edited_by = module.published_date = None module.subtree_edited_by = module.published_on = None
raw_metadata = json_data.get('metadata', {}) raw_metadata = json_data.get('metadata', {})
# published_date was previously stored as a list of time components instead of a datetime # published_on was previously stored as a list of time components instead of a datetime
if raw_metadata.get('published_date'): if raw_metadata.get('published_date'):
module.published_date = datetime(*raw_metadata.get('published_date')[0:6]).replace(tzinfo=UTC) module.published_on = datetime(*raw_metadata.get('published_date')[0:6]).replace(tzinfo=UTC)
module.published_by = raw_metadata.get('published_by') module.published_by = raw_metadata.get('published_by')
# otherwise restore the stored editing information # otherwise restore the stored editing information
else: else:
...@@ -250,7 +250,7 @@ class CachingDescriptorSystem(MakoDescriptorSystem): ...@@ -250,7 +250,7 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
module.edited_on = edit_info.get('edited_on') module.edited_on = edit_info.get('edited_on')
module.subtree_edited_on = edit_info.get('subtree_edited_on') module.subtree_edited_on = edit_info.get('subtree_edited_on')
module.subtree_edited_by = edit_info.get('subtree_edited_by') module.subtree_edited_by = edit_info.get('subtree_edited_by')
module.published_date = edit_info.get('published_date') module.published_on = edit_info.get('published_date')
module.published_by = edit_info.get('published_by') module.published_by = edit_info.get('published_by')
# decache any computed pending field settings # decache any computed pending field settings
...@@ -1185,12 +1185,12 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase): ...@@ -1185,12 +1185,12 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase):
xblock.edited_by = user_id xblock.edited_by = user_id
xblock.subtree_edited_on = now xblock.subtree_edited_on = now
xblock.subtree_edited_by = user_id xblock.subtree_edited_by = user_id
if not hasattr(xblock, 'published_date'): if not hasattr(xblock, 'published_on'):
xblock.published_date = None xblock.published_on = None
if not hasattr(xblock, 'published_by'): if not hasattr(xblock, 'published_by'):
xblock.published_by = None xblock.published_by = None
if isPublish: if isPublish:
xblock.published_date = now xblock.published_on = now
xblock.published_by = user_id xblock.published_by = user_id
# recompute (and update) the metadata inheritance tree which is cached # recompute (and update) the metadata inheritance tree which is cached
......
...@@ -12,10 +12,11 @@ import logging ...@@ -12,10 +12,11 @@ import logging
from opaque_keys.edx.locations import Location from opaque_keys.edx.locations import Location
from xmodule.exceptions import InvalidVersionError from xmodule.exceptions import InvalidVersionError
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.exceptions import ItemNotFoundError, DuplicateItemError, DuplicateCourseError from xmodule.modulestore.exceptions import (
ItemNotFoundError, DuplicateItemError, DuplicateCourseError, InvalidBranchSetting
)
from xmodule.modulestore.mongo.base import ( from xmodule.modulestore.mongo.base import (
MongoModuleStore, MongoRevisionKey, as_draft, as_published, MongoModuleStore, MongoRevisionKey, as_draft, as_published, SORT_REVISION_FAVOR_DRAFT
SORT_REVISION_FAVOR_DRAFT
) )
from xmodule.modulestore.store_utilities import rewrite_nonportable_content_links from xmodule.modulestore.store_utilities import rewrite_nonportable_content_links
from xmodule.modulestore.draft_and_published import UnsupportedRevisionError, DIRECT_ONLY_CATEGORIES from xmodule.modulestore.draft_and_published import UnsupportedRevisionError, DIRECT_ONLY_CATEGORIES
......
...@@ -783,7 +783,7 @@ class TestMongoModuleStore(unittest.TestCase): ...@@ -783,7 +783,7 @@ class TestMongoModuleStore(unittest.TestCase):
def test_update_published_info(self): def test_update_published_info(self):
""" """
Tests that published_date and published_by are set correctly Tests that published_on and published_by are set correctly
""" """
location = Location('edX', 'toy', '2012_Fall', 'html', 'test_html') location = Location('edX', 'toy', '2012_Fall', 'html', 'test_html')
create_user = 123 create_user = 123
...@@ -803,7 +803,7 @@ class TestMongoModuleStore(unittest.TestCase): ...@@ -803,7 +803,7 @@ class TestMongoModuleStore(unittest.TestCase):
updated_component = self.draft_store.get_item(location) updated_component = self.draft_store.get_item(location)
# Verify the time order and that publish_user caused publication # Verify the time order and that publish_user caused publication
self.assertLessEqual(old_time, updated_component.published_date) self.assertLessEqual(old_time, updated_component.published_on)
self.assertEqual(updated_component.published_by, publish_user) self.assertEqual(updated_component.published_by, publish_user)
def test_migrate_published_info(self): def test_migrate_published_info(self):
...@@ -829,7 +829,7 @@ class TestMongoModuleStore(unittest.TestCase): ...@@ -829,7 +829,7 @@ class TestMongoModuleStore(unittest.TestCase):
# Retrieve the block and verify its fields # Retrieve the block and verify its fields
component = self.draft_store.get_item(location) component = self.draft_store.get_item(location)
self.assertEqual(component.published_date, published_date) self.assertEqual(component.published_on, published_date)
self.assertEqual(component.published_by, published_by) self.assertEqual(component.published_by, published_by)
def test_export_course_with_peer_component(self): def test_export_course_with_peer_component(self):
......
...@@ -124,7 +124,7 @@ class XmlDescriptor(XModuleDescriptor): ...@@ -124,7 +124,7 @@ class XmlDescriptor(XModuleDescriptor):
# import and export. # import and export.
metadata_to_strip = ('data_dir', metadata_to_strip = ('data_dir',
'tabs', 'grading_policy', 'published_by', 'published_date', 'tabs', 'grading_policy',
'discussion_blackouts', 'discussion_blackouts',
# VS[compat] -- remove the below attrs once everything is in the CMS # VS[compat] -- remove the below attrs once everything is in the CMS
'course', 'org', 'url_name', 'filename', 'course', 'org', 'url_name', 'filename',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment