Source code for registration.management.commands.import_registrations

from django.core.management.base import BaseCommand, CommandError

from registration.models import import_registrations

[docs]class Command(BaseCommand): help = 'Import a csv file from Google Forms.'
[docs] def add_arguments(self, parser): parser.add_argument('file', nargs=1, type=str)
[docs] def handle(self, *args, **options): f = open(options['file'][0], newline='') stats = import_registrations(f) self.stdout.write(self.style.SUCCESS('Added {added}, skipped {skipped}.'.format(**stats)))