Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export form serials #809

Merged
merged 4 commits into from
May 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions apollo/submissions/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,20 @@ def export_list(self, query):

sample_headers = [s.name for s in samples]

dataset_headers = [
if form.form_type == 'SURVEY':
dataset_headers = [_('Serial')]
else:
dataset_headers = []

dataset_headers.extend([
_('Participant ID'), _('Name'), _('DB Phone'), _('Recent Phone')
] + [
loc_type.name for loc_type in location_types
] + [
_('Location'), _('Location Code'), _('Latitude'), _('Longitude')
] + extra_field_headers + [
_('Registered Voters')
] + tags + [_('Timestamp')]
] + tags + [_('Timestamp')])

if form.form_type == 'INCIDENT':
dataset_headers.extend([_('Status'), _('Description')])
Expand All @@ -85,14 +90,16 @@ def export_list(self, query):
else:
extra_data_columns = [''] * len(extra_fields)

record = [
record = [submission.serial_no] if form.form_type == 'SURVEY' else [] # noqa

record.extend([
submission.participant.participant_id
if submission.participant else '',
submission.participant.name
if submission.participant else '',
submission.participant.primary_phone
if submission.participant else '',
submission.last_phone_number if submission.last_phone_number else '',
submission.last_phone_number if submission.last_phone_number else '', # noqa
] + [
submission.location.make_path().get(loc_type.name, '')
for loc_type in location_types
Expand All @@ -106,7 +113,7 @@ def export_list(self, query):
] + [
export_field_value(form, submission, tag)
for tag in tags
]
])

record += [
submission.updated.strftime('%Y-%m-%d %H:%M:%S')
Expand All @@ -130,7 +137,10 @@ def export_list(self, query):
]
else:
extra_data_columns = [''] * len(extra_fields)
record = [

record = [sib.serial_no] if form.form_type == 'SURVEY' else []

record.extend([
sib.participant.participant_id
if sib.participant else '',
sib.participant.name
Expand All @@ -150,7 +160,7 @@ def export_list(self, query):
sib.location.registered_voters
] + [
export_field_value(form, submission, tag)
for tag in tags]
for tag in tags])

record += [
sib.updated.strftime('%Y-%m-%d %H:%M:%S')
Expand Down
4 changes: 2 additions & 2 deletions apollo/submissions/views_submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ def submission_list(form_id):
'participant': s.participant.name,
'participant_id': s.participant.participant_id,
'phone': s.participant.primary_phone,
'last_updated': s.participant_updated.strftime('%b %d, %Y %l:%M %p'), # noqa
'last_updated_timestamp': s.participant_updated.strftime('%s'), # noqa
'last_updated': s.participant_updated.strftime('%b %d, %Y %l:%M %p') if s.participant_updated else None, # noqa
'last_updated_timestamp': s.participant_updated.strftime('%s') if s.participant_updated else None, # noqa
}))
feature_collection = geojson.FeatureCollection(features)

Expand Down