Skip to content

Commit 783adf7

Browse files
committed
Fix for congress.legislator methods, including adding support for OCD id. Make sure to return None when there are no results.
1 parent 4b7f944 commit 783adf7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sunlight/services/congress.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
LEGISLATOR_ID_TYPES = (
2020
'bioguide',
21+
'ocd',
2122
'thomas',
2223
'lis',
2324
'govtrack',
@@ -73,6 +74,7 @@ def legislator(self, identifier, id_type=LEGISLATOR_ID_TYPES[0], **kwargs):
7374
bioguide. Choices are:
7475
7576
* bioguide
77+
* ocd
7678
* thomas
7779
* lis
7880
* govtrack
@@ -90,11 +92,11 @@ def legislator(self, identifier, id_type=LEGISLATOR_ID_TYPES[0], **kwargs):
9092
id_arg['fec_ids'] = identifier
9193
else:
9294
id_key = '{0}_id'.format(id_type)
93-
id_arg[id_key] = identifier
95+
id_arg[id_key] = '"{0}"'.format(identifier)
9496

9597
kwargs.update(id_arg)
9698
results = self.get(['legislators'], **kwargs)
97-
if len(results):
99+
if results and len(results):
98100
return EntityDict(results[0], results._meta)
99101
return None
100102

@@ -159,7 +161,7 @@ def bill(self, bill_id, **kwargs):
159161
"bill_id": bill_id
160162
})
161163
results = self.get(['bills'], **kwargs)
162-
if len(results):
164+
if results and len(results):
163165
return EntityDict(results[0], results._meta)
164166
return None
165167

@@ -297,4 +299,4 @@ def _decode_response(self, response):
297299
if results:
298300
return EntityList(results, data)
299301
else:
300-
return data
302+
return None

0 commit comments

Comments
 (0)