# Path: sitegeist/data/contributions/models.py
# class Contribution(models.Model):
#     zipcode = models.CharField(max_length=5)
#     total = models.DecimalField(max_digits=12, decimal_places=2, blank=True, null=True)
#     republicans = models.DecimalField(max_digits=12, decimal_places=2, blank=True, null=True)
#     democrats = models.DecimalField(max_digits=12, decimal_places=2, blank=True, null=True)\
# 
#     class Meta:
#         ordering = ('zipcode',)
# 
#     def __unicode__(self):
#         return self.zipcode


import csv
import os
from django.conf import settings
from sitegeist.data.contributions.models import Contribution




def reset():
    Contribution.objects.all().delete()


def load_contributions():

    cache_dir = settings.SITEGEIST['DATA_CACHE']
    inpath = os.path.join(cache_dir, 'contributions', 'contribs_by_zip.csv')

    with open(inpath) as infile:

        reader = csv.DictReader(infile)

        for record in reader:

# Path: sitegeist/data/contributions/models.py
# class Contribution(models.Model):
#     zipcode = models.CharField(max_length=5)
#     total = models.DecimalField(max_digits=12, decimal_places=2, blank=True, null=True)
#     republicans = models.DecimalField(max_digits=12, decimal_places=2, blank=True, null=True)
#     democrats = models.DecimalField(max_digits=12, decimal_places=2, blank=True, null=True)\
# 
#     class Meta:
#         ordering = ('zipcode',)
# 
#     def __unicode__(self):
#         return self.zipcode


# Path: sitegeist/data/contributions/loading.py
import csv
import os
from django.conf import settings
from sitegeist.data.contributions.models import Contribution





def reset():
    Contribution.objects.all().delete()


def load_contributions():

    cache_dir = settings.SITEGEIST['DATA_CACHE']
    inpath = os.path.join(cache_dir, 'contributions', 'contribs_by_zip.csv')

    with open(inpath) as infile:

        reader = csv.DictReader(infile)

        for record in reader:

            Contribution.objects.create(