Allow for saving specific attributes on resource models.
Review Request #6590 — Created Nov. 14, 2014 and submitted
Backbone's
save()
method accepts an 'attrs' option that contains a
dictionary of attribute names and new values. That's nice and all, but
there are times when you already have data set and want to just specify
which attributes to save.Our version of
save()
now allows attrs to be an array of attribute
names. Those attributes will be fetched from the payload and saved,
without any of the other attributes on the model.Care needs to be taken to only use this option when you know that the
save operation will only require those attributes. Creation of certain
resources may require additional attributes, as may an extension's
extra_data in certain cases. Rather than using this in everysave()
call, we should only it where we know it'll make sense.Some call sites have been updated to use this for simple cases and for
resources working with multiple rich text fields, in order to prevent
stomping over those fields' values server-side.
Unit tests passed.
Inspected the payloads for the saves I've updated. I only saw the values
I expected to see, and the saves performed fine in every case. That covers
both PUT and POST (where applicable, namely the review reply code).Tested this with master, and saw that replies no longer resulted in text fields
containing "<p>" tags. The new review request dialog still needs to be updated
on master to take advantage of this to prevent reviews from having those tags.