website/conservancy/supporters/management/commands/export_stripe.py

33 lines
1.1 KiB
Python
Raw Normal View History

import csv
import sys
from django.core.management.base import BaseCommand
from ...models import SustainerOrder
class Command(BaseCommand):
help = "Closes the specified poll for voting"
def handle(self, *args, **options):
orders = SustainerOrder.objects.filter(paid_time__isnull=False).order_by('paid_time')
columns = ['order_time', 'payment_time', 'name', 'email', 'amount', 'transaction_id', 'public_ack', 'shirt_size', 'join_list', 'street', 'city', 'state', 'zip_code', 'country']
writer = csv.writer(sys.stdout)
writer.writerow(columns)
for order in orders:
writer.writerow([
order.created_time,
order.paid_time,
order.name,
order.email,
order.amount,
order.payment_id,
order.acknowledge_publicly,
repr(order.tshirt_size if order.tshirt_size else ''),
order.add_to_mailing_list,
order.street,
order.city,
order.state,
order.zip_code,
order.country,
])