Store published date in module metadata, and display it on draft pages

This commit is contained in:
Calen Pennington
2012-10-04 15:27:02 -04:00
parent 1a8532d8ad
commit 1328fc5ac0
5 changed files with 43 additions and 19 deletions

View File

@@ -1,3 +1,4 @@
from datetime import datetime
from . import ModuleStoreBase, Location
from .exceptions import ItemNotFoundError
@@ -141,7 +142,10 @@ class DraftModuleStore(ModuleStoreBase):
Save a current draft to the underlying modulestore
"""
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_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)