Tweak to Project update

Now we use utils.remove_none_attributes to remove None values, and
revert to file _id only if it exists.
This commit is contained in:
2016-03-16 16:08:51 +01:00
parent 42fd0aebd9
commit bcde995e64

View File

@@ -46,13 +46,12 @@ class Project(List, Find, Create, Post, Update, Delete, Replace):
attributes.pop('_updated', None)
attributes.pop('_links', None)
attributes.pop('allowed_methods')
# Remove fields with None value (causes error on validation)
# Strip embedded image file properties and revert to ObjectId
for prop in ['picture_square', 'picture_header']:
if prop in attributes and attributes[prop] is None:
attributes.pop(prop)
# Strip embedded image file properties and revert to ObjectId
elif type(attributes[prop]) is dict:
if prop in attributes and type(attributes[prop]) is dict:
attributes[prop] = attributes[prop]['_id']
# Remove None attributes
attributes = utils.remove_none_attributes(attributes)
url = utils.join_url(self.path, str(self['_id']))
headers = utils.merge_dict(
self.http_headers(),