From 0d10ea5d5fd1ce8ab55fc97aadfd2234c7cd84db Mon Sep 17 00:00:00 2001 From: Joshua Carp Date: Fri, 4 Sep 2015 17:20:23 -0400 Subject: [PATCH] Use list of election districts from 18F/1179. [Resolves #587] --- __init__.py | 4 ++-- openfecwebapp/views.py | 6 ++++++ templates/candidates-single.html | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index fa8dcbf1d..89853771d 100644 --- a/__init__.py +++ b/__init__.py @@ -86,12 +86,12 @@ def cycle_end(value): return datetime.datetime(value, 12, 31) -def get_election_url(candidate, cycle): +def get_election_url(candidate, cycle, district=None): return url_for( 'elections', office=candidate['office_full'].lower(), state=candidate['state'] if candidate['state'] != 'US' else None, - district=candidate['district'], + district=district or candidate['district'], cycle=cycle, ) diff --git a/openfecwebapp/views.py b/openfecwebapp/views.py index 93e4dfb65..275dbbb6b 100644 --- a/openfecwebapp/views.py +++ b/openfecwebapp/views.py @@ -80,4 +80,10 @@ def render_candidate(candidate, committees, cycle): tmpl_vars['committees_authorized'] = committees_authorized tmpl_vars['aggregate'] = aggregate_committees(committees_authorized) + tmpl_vars['elections'] = sorted( + zip(candidate['election_years'], candidate['election_districts']), + key=lambda pair: pair[0], + reverse=True, + ) + return render_template('candidates-single.html', **tmpl_vars) diff --git a/templates/candidates-single.html b/templates/candidates-single.html index a934ac148..bd2c5baf6 100644 --- a/templates/candidates-single.html +++ b/templates/candidates-single.html @@ -51,8 +51,8 @@

{{ name }}

  • Elections