Skip to content

Commit

Permalink
modified import script
Browse files Browse the repository at this point in the history
  • Loading branch information
prsnca committed May 17, 2014
1 parent a589e0b commit d9a3572
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions committeeVotes/management/commands/all_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "committeeVotes.settings") # Replace with your app name.

BILL_FIELDS = ['name','description']
BILL_FIELDS = ['name','description', 'oknesset_url']


#
#
# #Importing bills CSV
class Command(BaseCommand):
def handle(self, *args, **options):
Expand Down
14 changes: 10 additions & 4 deletions committeeVotes/management/commands/vote_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@

def get_meeting(date):
try:
meeting = Meeting.objects.get(took_place=date)
except ObjectDoesNotExist:
print "Meeting was not found!"
meeting = Meeting.objects.get_or_create(took_place=date)
print "got meeting!"
except MultipleObjectsReturned:
print "Few meetings were found!"
return None
return meeting
return meeting[0]

def get_bill(name):
try:
Expand Down Expand Up @@ -87,6 +88,11 @@ def handle(self, *args, **options):
except ValidationError:
print "error in vote"
continue
try:
vote.meeting.proposed_bills.add(vote.bill)
except:
print "error in adding bill to meeting"
continue

vote.save()

Expand Down
4 changes: 2 additions & 2 deletions committeeVotes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Bill(models.Model):
name = models.CharField(max_length=500)
description = models.TextField()
#oknesset_url = models.CharField(max_length=100, blank=True, null=True)
oknesset_url = models.CharField(max_length=100, blank=True, null=True)
def __unicode__(self):
return self.name

Expand All @@ -14,7 +14,7 @@ def __unicode__(self):
return self.typeName

class Meeting(models.Model):
took_place = models.DateField()
took_place = models.DateField(unique=True)
proposed_bills = models.ManyToManyField(Bill, blank=True)
def __unicode__(self):
return "Meeting #" + str(self.id) + u" - %s" % self.took_place
Expand Down

0 comments on commit d9a3572

Please sign in to comment.