From 5f0e237ab016004b276ddf7b0425ccb1bf22821f Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 9 Oct 2012 10:43:18 -0400 Subject: [PATCH] Store the id of the publishing user on publish --- cms/djangoapps/contentstore/views.py | 2 +- common/lib/xmodule/xmodule/modulestore/draft.py | 3 ++- common/lib/xmodule/xmodule/x_module.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 609f800951..d92190f645 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -527,7 +527,7 @@ def publish_draft(request): raise PermissionDenied() item = modulestore().get_item(location) - _xmodule_recurse(item, lambda i: modulestore().publish(i.location)) + _xmodule_recurse(item, lambda i: modulestore().publish(i.location, request.user.id)) return HttpResponse() diff --git a/common/lib/xmodule/xmodule/modulestore/draft.py b/common/lib/xmodule/xmodule/modulestore/draft.py index 671a710836..9c58b12e82 100644 --- a/common/lib/xmodule/xmodule/modulestore/draft.py +++ b/common/lib/xmodule/xmodule/modulestore/draft.py @@ -159,7 +159,7 @@ class DraftModuleStore(ModuleStoreBase): """ return super(DraftModuleStore, self).delete_item(as_draft(location)) - def publish(self, location): + def publish(self, location, published_by_id): """ Save a current draft to the underlying modulestore """ @@ -167,6 +167,7 @@ class DraftModuleStore(ModuleStoreBase): metadata = {} metadata.update(draft.metadata) metadata['published_date'] = tuple(datetime.utcnow().timetuple()) + metadata['published_by'] = published_by_id 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, metadata) diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index b0ea7772fb..e5405c7f4a 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -409,7 +409,7 @@ class XModuleDescriptor(Plugin, HTMLSnippet, ResourceTemplates): # cdodge: this is a list of metadata names which are 'system' metadata # and should not be edited by an end-user - system_metadata_fields = ['data_dir', 'published_date'] + system_metadata_fields = ['data_dir', 'published_date', 'published_by'] # A list of descriptor attributes that must be equal for the descriptors to # be equal