2024-10-08 15:01:32 +00:00
|
|
|
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):
|
2024-10-11 10:58:46 +00:00
|
|
|
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']
|
2024-10-08 15:01:32 +00:00
|
|
|
writer = csv.writer(sys.stdout)
|
|
|
|
writer.writerow(columns)
|
|
|
|
for order in orders:
|
|
|
|
writer.writerow([
|
|
|
|
order.created_time,
|
2024-10-11 10:58:46 +00:00
|
|
|
order.paid_time,
|
2024-10-08 15:01:32 +00:00
|
|
|
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,
|
|
|
|
])
|