Commit d5576986 by Chris Dodge

check if 'delete metadata field' is not in the list of system metadata

parent 95e15c44
......@@ -448,13 +448,14 @@ def save_item(request):
# fetch original
existing_item = modulestore().get_item(item_location)
logging.debug(posted_metadata)
# update existing metadata with submitted metadata (which can be partial)
# IMPORTANT NOTE: if the client passed pack 'null' (None) for a piece of metadata that means 'remove it'
for metadata_key in posted_metadata.keys():
if posted_metadata[metadata_key] is None:
# NOTE: We don't want clients to be able to delete 'system metadata' which are not intended to be user
# editable
if posted_metadata[metadata_key] is None and metadata_key not in existing_item.system_metadata_fields:
# remove both from passed in collection as well as the collection read in from the modulestore
if metadata_key in existing_item.metadata:
del existing_item.metadata[metadata_key]
del posted_metadata[metadata_key]
......
......@@ -95,11 +95,10 @@ function saveSubsection(e) {
metadata[$(el).data("metadata-name")] = el.value;
}
// OK, we have some metadata (namely 'Release Date' (aka 'start') and 'Due Date') which has been normalized in the UI
// we have to piece it back together. Unfortunate 'start' and 'due' use different string formatters. Rather than try to
// replicate the string formatting which is used in the backend here in JS, let's just pass back a unified format
// and let the server re-format into the expected persisted format
// Piece back together the date/time UI elements into one date/time string
// NOTE: our various "date/time" metadata elements don't always utilize the same formatting string
// so make sure we're passing back the correct format
metadata['start'] = getEdxTimeFromDateTimeInputs('start_date', 'start_time');
metadata['due'] = getEdxTimeFromDateTimeInputs('due_date', 'due_time', 'MMMM dd HH:mm');
......
/************************
datepair.js
This is a component of the jquery-timepicker plugin
http://jonthornton.github.com/jquery-timepicker/
requires jQuery 1.6+
version: 1.2.2
************************/
$(function() {
$('.datepair input.date').each(function(){
......
......@@ -3,6 +3,8 @@ jquery-timepicker
http://jonthornton.github.com/jquery-timepicker/
requires jQuery 1.6+
version: 1.2.2
************************/
......
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