Skip to content

Commit

Permalink
[#477] Replaced created_at and last_modified_at with null instead of …
Browse files Browse the repository at this point in the history
…True
  • Loading branch information
KasperBrandt committed Jun 6, 2014
1 parent 4a6f797 commit 231f5e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion akvo/api/resources/organisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ class Meta:
)

def dehydrate(self, bundle):
""" add thumbnails inline info for Organisation.logo
"""check if created_at and last_modified_at are boolean instead of null
add thumbnails inline info for Organisation.logo
"""
bundle = super(OrganisationResource, self).dehydrate(bundle)
if isinstance(bundle.data['created_at'], bool):
bundle.data['created_at'] = None
if isinstance(bundle.data['last_modified_at'], bool):
bundle.data['last_modified_at'] = None
bundle.data['logo'] = {
'original': bundle.data['logo'],
'thumbnails': get_extra_thumbnails(bundle.obj.logo),
Expand Down
4 changes: 4 additions & 0 deletions akvo/api/resources/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ def dehydrate(self, bundle):
""" add thumbnails inline info for Project.current_image
"""
bundle = super(ProjectResource, self).dehydrate(bundle)
if isinstance(bundle.data['created_at'], bool):
bundle.data['created_at'] = None
if isinstance(bundle.data['last_modified_at'], bool):
bundle.data['last_modified_at'] = None
bundle.data['current_image'] = {
'original': bundle.data['current_image'],
'thumbnails': get_extra_thumbnails(bundle.obj.current_image),
Expand Down
3 changes: 3 additions & 0 deletions akvo/api/resources/project_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def dehydrate(self, bundle):
bundle.data['time_last_updated'] = bundle.data['last_modified_at']
del bundle.data['created_at']
del bundle.data['last_modified_at']
if isinstance(bundle.data['time'], bool): bundle.data['time'] = None
if isinstance(bundle.data['time_last_updated'], bool): bundle.data['time_last_updated'] = None
return bundle


Expand Down Expand Up @@ -130,6 +132,7 @@ def project_data_for_update(bundle):
bundle.data['user']['organisation'].update(primary_location=primary_location_data_for_update(organisation))
bundle.data['project'] = project_data_for_update(bundle)
bundle.data['project'].update(primary_location=primary_location_data_for_update(bundle.obj.project))

return bundle

def build_schema(self):
Expand Down

0 comments on commit 231f5e5

Please sign in to comment.