Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ which by default will run in docker.
* Follow instructions for [working on openstates.org](https://docs.openstates.org/contributing/openstates-org/)
from the docs.
* Quirks I ran into:
* 2025: hit error `ERR_OSSL_EVP_UNSUPPORTED` when running `npm run build` so fixed by running `export NODE_OPTIONS=--openssl-legacy-provider`
* `npm run start` did not actually make JS/CSS available when I hit the app at `localhost:8000`. Instead I
ran `npm run build` and then rebuilt the docker containers with `docker compose build`, finally started them
again.
Expand Down
6 changes: 3 additions & 3 deletions ansible/inventory/host_vars/openstates.org.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ django_environment:
NEW_RELIC_APP_NAME: "openstates.org"

# postgres
pg_password: "{{ lookup('aws_ssm', '/bobsled/backups/PGPASSWORD') }}"
pg_host: "{{ lookup('aws_ssm', '/bobsled/backups/PGHOST') }}"
pg_user: "{{ lookup('aws_ssm', '/bobsled/backups/PGUSER') }}"
pg_password: "{{ lookup('aws_ssm', '/passwords/osorg_db_password') }}"
pg_host: "openstates.cn70ucbuuwc7.us-east-1.rds.amazonaws.com"
pg_user: os_django
pg_port: 5432
pg_database: openstatesorg
2 changes: 1 addition & 1 deletion ansible/openstates/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@

become_user: "openstates"
- name: install packages via poetry
command: python3.9 -m poetry install # --deploy
command: python3.9 -m poetry install --no-root # --deploy
changed_when: false
args:
chdir: /home/openstates/src/openstates.org
Expand Down
66 changes: 2 additions & 64 deletions public/views/legislators.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,73 +96,11 @@ def legislators(request, state):


def person(request, person_id):
SPONSORED_BILLS_TO_SHOW = 4
RECENT_VOTES_TO_SHOW = 3

try:
ocd_person_id = decode_uuid(person_id)
except ValueError:
ocd_person_id = (
person_id # will be invalid and raise 404, but useful in logging later
)
person = get_object_or_404(
Person.objects.prefetch_related("memberships__organization"),
pk=ocd_person_id,
)

# to display district in front of district name, or not?
district_maybe = ""

# canonicalize the URL
canonical_url = pretty_url(person)
if request.path != canonical_url:
return redirect(canonical_url, permanent=True)

if not person.current_jurisdiction_id:
state = None
retired = True
elif not person.current_role:
# this breaks if they held office in two states, but we don't really worry about that
state = jid_to_abbr(person.current_jurisdiction_id)
retired = True
else:
state = jid_to_abbr(person.current_jurisdiction_id)
retired = False
# does it start with a number?
if str(person.current_role["district"])[0] in "0123456789":
district_maybe = "District"
person.all_links = list(person.links.all())
person.all_offices = list(person.offices.all())

person.sponsored_bills = list(
Bill.objects.all()
.select_related(
"legislative_session",
"legislative_session__jurisdiction",
)
.filter(sponsorships__person=person)
.order_by("-created_at", "id")[:SPONSORED_BILLS_TO_SHOW]
)

votes = (
person.votes.all()
.select_related("vote_event", "vote_event__bill")
.order_by("-vote_event__start__date")[:RECENT_VOTES_TO_SHOW]
)
person.vote_events = []
for vote in votes:
vote_event = vote.vote_event
vote_event.legislator_vote = vote
person.vote_events.append(vote_event)

return render(
request,
"public/views/legislator.html",
{
"state": state,
"person": person,
"state_nav": "legislators",
"retired": retired,
"district_maybe": district_maybe,
},
)
redirect_person_id = ocd_person_id.replace("ocd-person/", "")
return redirect(f"https://pluralpolicy.com/app/person/{redirect_person_id}/", permanent=True)
Loading