Skip to content

Commit

Permalink
Use list of election districts from 18F/1179.
Browse files Browse the repository at this point in the history
[Resolves fecgov#587]
  • Loading branch information
jmcarp committed Sep 4, 2015
1 parent 021c99b commit 0d10ea5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
6 changes: 6 additions & 0 deletions openfecwebapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions templates/candidates-single.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ <h1 class="entity__name">{{ name }}</h1>
<li class="entity__term">
<span class="entity__term__label">Elections</span>
<ul class="entity__term__data">
{% for year in election_years %}
<a href="{{ election_url(context(), year) }}">{{ year }}</a>{% if loop.last == false %},{% endif %}
{% for year, district in elections %}
<a href="{{ election_url(context(), year, district) }}">{{ year }}</a>{% if loop.last == false %},{% endif %}
{% endfor %}
</ul>
</li>
Expand Down

0 comments on commit 0d10ea5

Please sign in to comment.