Permalink
Browse files

Added checks for missing candidates and committees

  • Loading branch information...
1 parent 71d7fbf commit 8fef0aaab96c8f829d5e8e03958c3fc1651a7ba5 Ethan Phelps-Goodman committed Apr 11, 2012
View
9 dcdata/management/commands/crp_denormalize.py
@@ -25,10 +25,11 @@ def add_recipient(self, record, committee):
# cmte_id != recip_id indicates a candidate committee
if committee['cmte_id'] != committee['recip_id']:
candidate = self._candidates.get('%s:%s' % (record['cycle'], committee['fec_cand_id'].strip().upper()), None)
- self.add_candidate_recipient(record, candidate, committee)
- else:
- self.add_committee_recipient(record, committee)
-
+ if candidate:
+ self.add_candidate_recipient(record, candidate, committee)
+ return record
+
+ self.add_committee_recipient(record, committee)
return record
View
3 dcdata/management/commands/crp_denormalize_pac2candidate.py
@@ -17,7 +17,8 @@ def __init__(self, candidates):
def process_record(self, record):
candidate = self._candidates.get('%s:%s' % (record['cycle'], record['fec_cand_id'].upper()), "")
- self.add_candidate_recipient(record, candidate, None)
+ if candidate:
+ self.add_candidate_recipient(record, candidate, None)
return record
class ContributorFilter(Filter):
View
9 dcdata/management/commands/crp_denormalize_pac2pac.py
@@ -63,15 +63,18 @@ def __init__(self, candidates, committees):
def process_record(self, record):
if record['type'].startswith('1'): # filer is recipient
committee = self._committees.get('%s:%s' % (record['cycle'], record['filer_id'].strip().upper()), None)
- self.add_recipient(record, committee)
+ if committee:
+ self.add_recipient(record, committee)
else: # transaction type starts with 2: filer is donor, use other_id for recipient
id = record['other_id'].strip().upper()
if id.startswith('C'):
committee = self._committees.get('%s:%s' % (record['cycle'], id), None)
- self.add_recipient(record, committee)
+ if committee:
+ self.add_recipient(record, committee)
else:
candidate = self._candidates.get('%s:%s' % (record['cycle'], id), None)
- self.add_candidate_recipient(record, candidate, None)
+ if candidate:
+ self.add_candidate_recipient(record, candidate, None)
return record

0 comments on commit 8fef0aa

Please sign in to comment.