From a262592b06c874e08ddc0df316fd784443277a0d Mon Sep 17 00:00:00 2001 From: Ion Y Date: Tue, 23 Aug 2022 16:31:22 -0700 Subject: [PATCH] Add party abbreviations to candidates. Fixes BallotLab #83. --- src/electos/ballotmaker/scripts/ballot-lab-data.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/electos/ballotmaker/scripts/ballot-lab-data.py b/src/electos/ballotmaker/scripts/ballot-lab-data.py index 3db154c..a3cf618 100644 --- a/src/electos/ballotmaker/scripts/ballot-lab-data.py +++ b/src/electos/ballotmaker/scripts/ballot-lab-data.py @@ -84,10 +84,15 @@ def candidate_name(candidate: Candidate): def candidate_party(candidate: Candidate, index): - """Get the name of the party of a candidate as it appears on a ballot.""" + """Get the name and abbreviation of the party of a candidate as it appears on a ballot.""" party = index.by_id(candidate.party_id) name = text_content(party.name) if party else "" - return name + abbreviation = text_content(party.abbreviation) if party and party.abbreviation else "" + result = { + "name": name, + "abbreviation": abbreviation, + } + return result def candidate_contest_offices(contest: CandidateContest, index):