From bcde995e64408faa8f7a408ee6d98ecd41350a38 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Wed, 16 Mar 2016 16:08:51 +0100 Subject: [PATCH] Tweak to Project update Now we use utils.remove_none_attributes to remove None values, and revert to file _id only if it exists. --- pillarsdk/projects.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pillarsdk/projects.py b/pillarsdk/projects.py index a338eb5..658b1f6 100644 --- a/pillarsdk/projects.py +++ b/pillarsdk/projects.py @@ -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(),