Skip to content

Commit

Permalink
Keep track of whether all attachments have been submitted
Browse files Browse the repository at this point in the history
Fixes: #1049

Add new fields to the model instance to keep track of:

- How many attachments, if any are expected in a submission
- How many attachments have been actually received
- Whether all attachments have been received
  • Loading branch information
moshthepitt authored and ukanga committed Aug 25, 2017
1 parent 8598f04 commit 61e2551
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions onadata/libs/utils/logger_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ def save_attachments(xform, instance, media_files):
extension=extension)
update_instance_attachment_tracking(instance)

instance.total_media = len([m for m in instance.get_dict().keys() if m in
xform.get_media_survey_xpaths()])
instance.media_count = instance.attachments.count()
instance.media_all_received = instance.media_count == \
instance.total_media
instance.save(update_fields=['total_media',
'media_count',
'media_all_received'])


def save_submission(xform, xml, media_files, new_uuid, submitted_by, status,
date_created_override):
Expand Down

0 comments on commit 61e2551

Please sign in to comment.