From 85fa712fdf4ebd19b922da3f418accf4743995ae Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Wed, 27 Aug 2014 16:12:44 -0400 Subject: [PATCH] Change published_date to published_on to make consistent with other edit info timestamps LMS-11184 --- cms/djangoapps/contentstore/views/item.py | 2 +- .../xmodule/xmodule/modulestore/mongo/base.py | 16 ++++++++-------- .../xmodule/xmodule/modulestore/mongo/draft.py | 7 ++++--- .../xmodule/modulestore/tests/test_mongo.py | 6 +++--- common/lib/xmodule/xmodule/xml_module.py | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index 6da18ae47a..76825e9b3e 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -666,7 +666,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F "category": xblock.category, "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, + "published_on": get_default_time_display(xblock.published_on) if xblock.published_on else None, "studio_url": xblock_studio_url(xblock, parent_xblock), "released_to_students": datetime.now(UTC) > xblock.start, "release_date": release_date, diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/base.py b/common/lib/xmodule/xmodule/modulestore/mongo/base.py index 05a3729497..e0e39a28e5 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/base.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/base.py @@ -235,14 +235,14 @@ class CachingDescriptorSystem(MakoDescriptorSystem): 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: 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', {}) - # 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'): - 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') # otherwise restore the stored editing information else: @@ -250,7 +250,7 @@ class CachingDescriptorSystem(MakoDescriptorSystem): module.edited_on = edit_info.get('edited_on') module.subtree_edited_on = edit_info.get('subtree_edited_on') 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') # decache any computed pending field settings @@ -1185,12 +1185,12 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase): xblock.edited_by = user_id xblock.subtree_edited_on = now xblock.subtree_edited_by = user_id - if not hasattr(xblock, 'published_date'): - xblock.published_date = None + if not hasattr(xblock, 'published_on'): + xblock.published_on = None if not hasattr(xblock, 'published_by'): xblock.published_by = None if isPublish: - xblock.published_date = now + xblock.published_on = now xblock.published_by = user_id # recompute (and update) the metadata inheritance tree which is cached diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/draft.py b/common/lib/xmodule/xmodule/modulestore/mongo/draft.py index 95882cdb3b..fa99775beb 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/draft.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/draft.py @@ -12,10 +12,11 @@ import logging from opaque_keys.edx.locations import Location from xmodule.exceptions import InvalidVersionError 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 ( - MongoModuleStore, MongoRevisionKey, as_draft, as_published, - SORT_REVISION_FAVOR_DRAFT + MongoModuleStore, MongoRevisionKey, as_draft, as_published, SORT_REVISION_FAVOR_DRAFT ) from xmodule.modulestore.store_utilities import rewrite_nonportable_content_links from xmodule.modulestore.draft_and_published import UnsupportedRevisionError, DIRECT_ONLY_CATEGORIES diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py index 2791a7e33b..84d845eea2 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py @@ -783,7 +783,7 @@ class TestMongoModuleStore(unittest.TestCase): 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') create_user = 123 @@ -803,7 +803,7 @@ class TestMongoModuleStore(unittest.TestCase): updated_component = self.draft_store.get_item(location) # 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) def test_migrate_published_info(self): @@ -829,7 +829,7 @@ class TestMongoModuleStore(unittest.TestCase): # Retrieve the block and verify its fields 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) def test_export_course_with_peer_component(self): diff --git a/common/lib/xmodule/xmodule/xml_module.py b/common/lib/xmodule/xmodule/xml_module.py index f5117ed223..dc9a3931da 100644 --- a/common/lib/xmodule/xmodule/xml_module.py +++ b/common/lib/xmodule/xmodule/xml_module.py @@ -124,7 +124,7 @@ class XmlDescriptor(XModuleDescriptor): # import and export. metadata_to_strip = ('data_dir', - 'tabs', 'grading_policy', 'published_by', 'published_date', + 'tabs', 'grading_policy', 'discussion_blackouts', # VS[compat] -- remove the below attrs once everything is in the CMS 'course', 'org', 'url_name', 'filename',