Skip to content

Commit

Permalink
Format Attachment deleted_at field
Browse files Browse the repository at this point in the history
  • Loading branch information
WinnyTroy committed Feb 6, 2020
1 parent 615193f commit b638768
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 3 additions & 6 deletions onadata/apps/api/tests/viewsets/test_data_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,8 +1266,7 @@ def test_same_submission_with_different_attachments(self):
'filename': attachment.media_file.name,
'name': attachment.name,
'id': attachment.pk,
'xform': xform.id,
'deleted_at': None}
'xform': xform.id}
],
'_geolocation': [None, None],
'_xform_id_string': xform.id_string,
Expand Down Expand Up @@ -1299,8 +1298,7 @@ def test_same_submission_with_different_attachments(self):
'filename': attachment.media_file.name,
'name': attachment.name,
'id': attachment.pk,
'xform': xform.id,
'deleted_at': None
'xform': xform.id
}]
self.maxDiff = None
response = view(request, pk=formid)
Expand Down Expand Up @@ -1339,8 +1337,7 @@ def test_data_w_attachment(self):
'filename': self.attachment.media_file.name,
'name': self.attachment.name,
'id': self.attachment.pk,
'xform': self.xform.id,
'deleted_at': None},
'xform': self.xform.id}
],
'_geolocation': [None, None],
'_xform_id_string': 'transportation_2011_07_25',
Expand Down
4 changes: 3 additions & 1 deletion onadata/apps/logger/models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ def _get_attachments_from_instance(instance):
attachment['mimetype'] = a.mimetype
attachment['filename'] = a.media_file.name
attachment['name'] = a.name
attachment['deleted_at'] = a.deleted_at
attachment['instance'] = a.instance.pk
attachment['xform'] = instance.xform.id
attachment['id'] = a.id
attachments.append(attachment)

if isinstance(a.deleted_at, datetime):
attachment['deleted_at'] = a.deleted_at.strftime(MONGO_STRFTIME)

return attachments


Expand Down

0 comments on commit b638768

Please sign in to comment.