From 00e0ce95a4936a34d1826e2844394b05f0b29286 Mon Sep 17 00:00:00 2001 From: "james@jwilkerson.me" Date: Thu, 20 Feb 2020 14:39:32 -0600 Subject: [PATCH 1/2] Added numrunoff to api query --- elex/api/models.py | 4 +++- elex/api/utils.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/elex/api/models.py b/elex/api/models.py index 706b039..dd692c2 100644 --- a/elex/api/models.py +++ b/elex/api/models.py @@ -625,6 +625,7 @@ def __init__(self, **kwargs): self.initialization_data = kwargs.get('initialization_data', False) self.national = kwargs.get('national', False) self.candidates = kwargs.get('candidates', []) + self.numrunoff = kwargs.get('numRunoff', None) self.reportingunits = kwargs.get('reportingUnits', []) self.is_ballot_measure = False @@ -782,7 +783,8 @@ def serialize(self): ('statename', self.statename), ('statepostal', self.statepostal), ('test', self.test), - ('uncontested', self.uncontested) + ('uncontested', self.uncontested), + ('numrunoff', self.numrunoff), )) def __unicode__(self): diff --git a/elex/api/utils.py b/elex/api/utils.py index 275bc32..0db13ad 100644 --- a/elex/api/utils.py +++ b/elex/api/utils.py @@ -84,6 +84,7 @@ def api_request(path, **params): `apiKey="`, your AP API key, or `national=True`, for national-only results. """ + params['apiKey'] = params.get('apiKey') or elex.API_KEY if not params['apiKey']: raise APAPIKeyException() @@ -94,8 +95,8 @@ def api_request(path, **params): url = '{0}{1}'.format(elex.BASE_URL, path.replace('//', '/')) response = cache.get(url, params=params) + # import ipdb; ipdb.set_trace() response.raise_for_status() - write_recording(response.json()) return response From 27733e3c473fef48676f8bdd56247bee49ad32ea Mon Sep 17 00:00:00 2001 From: "james@jwilkerson.me" Date: Thu, 20 Feb 2020 14:42:12 -0600 Subject: [PATCH 2/2] Removed some cruff --- elex/api/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/elex/api/utils.py b/elex/api/utils.py index 0db13ad..275bc32 100644 --- a/elex/api/utils.py +++ b/elex/api/utils.py @@ -84,7 +84,6 @@ def api_request(path, **params): `apiKey="`, your AP API key, or `national=True`, for national-only results. """ - params['apiKey'] = params.get('apiKey') or elex.API_KEY if not params['apiKey']: raise APAPIKeyException() @@ -95,8 +94,8 @@ def api_request(path, **params): url = '{0}{1}'.format(elex.BASE_URL, path.replace('//', '/')) response = cache.get(url, params=params) - # import ipdb; ipdb.set_trace() response.raise_for_status() + write_recording(response.json()) return response