def contributions(): contributions = Contribution.objects.filter(meta_data__processed=True) filename = "InfluenceExplorer/contributions.csv" contribution_file = default_storage.open(filename, 'wb') writer = UnicodeWriter(contribution_file) writer.writerow(contribution_heading) contributions_sheet(contributions, writer) contribution_file.close() print "done with contributions"
def payments(): payments = Payment.objects.filter(meta_data__processed=True) filename = "InfluenceExplorer/payments.csv" payment_file = default_storage.open(filename, 'wb') writer = UnicodeWriter(payment_file) writer.writerow(payment_heading) payments_sheet(payments, writer) payment_file.close() print "done with payments"
def disbursements(): disbursements = Disbursement.objects.filter(meta_data__processed=True) filename = "InfluenceExplorer/disbursements.csv" disbursement_file = default_storage.open(filename, 'wb') writer = UnicodeWriter(disbursement_file) writer.writerow(disbursement_heading) disbursements_sheet(disbursements, writer) disbursement_file.close() print "done with disbursements"
def make_contributions(docs): links = [] for d in docs: if d.processed == True: links.append(d.url) contributions = Contribution.objects.filter(link__in=links) if len(contributions) >=1: filename = "contributions.csv" writer = UnicodeWriter(open(filename, 'wb')) writer.writerow(contribution_heading) contributions_sheet(contributions, writer) return filename else: return None
def make_disbursements(docs): links = [] for d in docs: if d.processed == True: links.append(d.url) disbursements = Disbursement.objects.filter(link__in=links) if len(disbursements) >=1: filename = "disbursements.csv" writer = UnicodeWriter(open(filename, 'wb')) writer.writerow(disbursement_heading) disbursements_sheet(disbursements, writer) return filename else: return None
def make_contacts(docs): links = [] for d in docs: if d.processed == True: links.append(d.url) contacts = Contact.objects.filter(link__in=links) if len(contacts) >= 1: filename = "contacts.csv" contact_file = open(filename, 'wb') writer = UnicodeWriter(contact_file) writer.writerow(contact_heading) contact_sheet(contacts, writer) return filename else: return None
def make_disbursements(docs): links = [] for d in docs: if d.processed == True: links.append(d.url) disbursements = Disbursement.objects.filter(link__in=links) if len(disbursements) >= 1: filename = "disbursements.csv" writer = UnicodeWriter(open(filename, 'wb')) writer.writerow(disbursement_heading) disbursements_sheet(disbursements, writer) return filename else: return None
def make_contributions(docs): links = [] for d in docs: if d.processed == True: links.append(d.url) contributions = Contribution.objects.filter(link__in=links) if len(contributions) >= 1: filename = "contributions.csv" writer = UnicodeWriter(open(filename, 'wb')) writer.writerow(contribution_heading) contributions_sheet(contributions, writer) return filename else: return None
def create_contact(): pool = Contact.objects.filter(meta_data__processed=True) paginated_contacts = Paginator(pool, 500) page_range = paginated_contacts.page_range filename = "InfluenceExplorer/contacts.csv" with default_storage.open(filename, 'wb') as contact_file: writer = UnicodeWriter(contact_file) writer.writerow(contact_heading) # this was paginated to avoid horrendous garbage cleanup when I passes it all at once for n in page_range: contacts = paginated_contacts.page(n) contact_sheet(contacts, writer) print "done with contacts"
def handle(self, *args, **options): print "starting", datetime.datetime.now().time() #contacts contacts = list(Contact.objects.filter(meta_data__processed=True)) print "got contacts" filename = "InfluenceExplorer/contacts.csv" contact_file = default_storage.open(filename, 'wb') writer = UnicodeWriter(contact_file) writer.writerow(contact_heading) print 'starting contacts' contact_sheet(contacts, writer) print "done looping" contact_file.close() print "done with contacts" # client-registrant filename = "InfluenceExplorer/client_registrant.csv" cr_file = default_storage.open(filename, 'wb') writer = UnicodeWriter(cr_file) client_registrant(writer) cr_file.close() print "done with client registrant" # disbursements disbursements = Disbursement.objects.filter(meta_data__processed=True) filename = "InfluenceExplorer/disbursements.csv" disbursement_file = default_storage.open(filename, 'wb') writer = UnicodeWriter(disbursement_file) writer.writerow(disbursement_heading) disbursements_sheet(disbursements, writer) disbursement_file.close() print "done with disbursements" # contributions contributions = Contribution.objects.filter(meta_data__processed=True) filename = "InfluenceExplorer/contributions.csv" contribution_file = default_storage.open(filename, 'wb') writer = UnicodeWriter(contribution_file) writer.writerow(contribution_heading) contributions_sheet(contributions, writer) contribution_file.close() print "done with contributions" # payments payments = Payment.objects.filter(meta_data__processed=True) filename = "InfluenceExplorer/payments.csv" payment_file = default_storage.open(filename, 'wb') writer = UnicodeWriter(payment_file) writer.writerow(payment_heading) payments_sheet(payments, writer) payment_file.close() print "done with payments" print "ending", datetime.datetime.now().time()