-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Openstates v3 upgrade #41
Conversation
…nstates v3 api, no test failures, legacy test errors
data: { | ||
apikey: CallPower.Config.SUNLIGHT_API_KEY, | ||
apikey: CallPower.Config.OPENSTATES_API_KEY, | ||
state: campaign_state, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To work with the v3 api it looks like some of these params need to change
state
-- became jurisdiction
last_name
-- became just name
in_office
-- seems to not be supported at all anymore
chamber
-- became org_classification
and should be one of "legislature", "executive", "lower", "upper", or "government"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Down below in the renderSearchResults
function, some translation is also needed to hook the v3 api response up to the template in call_server/templates/campaign/form.html:167, which still expects the v1 attributes. This worked for me:
} else if (person.title === 'Governor') {
person.uid = 'us_state:governor:'+person.state
}
+ if (person.given_name) {
+ person.first_name = person.given_name;
+ person.last_name = person.family_name;
+ person.title = person.current_role.title;
+ person.state = person.jurisdiction.name;
+ }
+
// if person has multiple phones, use only the first office
if (person.phone === undefined && person.offices) {
if (person.offices) {
- person.phone = person.offices[0].phone;
+ person.phone = person.offices[0].voice;
}
@@ -54,9 +54,6 @@ | |||
<script> | |||
window.CallPower = { | |||
Config: { | |||
SUNLIGHT_API_KEY: "{{SUNLIGHT_API_KEY}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the front end to work we need to replace this config with the values for openstates.
{
OPENSTATES_URL: "https://v3.openstates.org/people?include=offices", // need offices in the response to get phone number
OPENSTATES_API_KEY: "..." // get from app config
}
The backend changes all look good to me. I noticed that custom target search in the campaign form no longer works, and noted some changes that at least make it render correctly for me. I'm not certain anyone actually uses this feature though, as it's also broken in prod due to loading mixed http/https content. It'd be fine with me to push ahead with the backend upgrades here and either circle back to the target search or just remove that part of the form. |
Openstates v1 is expiring, and the Sunlight foundation (through which we previously accessed v1) has sunsetted.
This may also take care of issue #15.