Skip to content

Commit

Permalink
Adds survey feedback csv output management command
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlemann committed Feb 7, 2018
1 parent 9440c80 commit 21e67cb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions schools/management/commands/output_survey_feedback.py
@@ -0,0 +1,22 @@
import csv
import sys

from django.core.management.base import BaseCommand
import schools.models as schools_models


class Command(BaseCommand):
help = 'Get a CSV of survey feedback'

def handle(self, *args, **options):
headers = ['name', 'created_at', 'type', 'feedback']
writer = csv.DictWriter(sys.stdout, fieldnames=headers)
writer.writeheader()
for profile in schools_models.SchoolProfile.objects.select_related('school').order_by('school__name','-created_at'):
row = {
'name': profile.school.name,
'created_at': profile.created_at,
'type': profile.school.type,
'feedback': profile.survey_feedback,
}
writer.writerow(row)

0 comments on commit 21e67cb

Please sign in to comment.