Skip to content
This repository has been archived by the owner on Dec 23, 2017. It is now read-only.

Feature/hide amendments candidate #527

Merged
merged 5 commits into from
Aug 26, 2015
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_election_url(candidate, cycle):
'cycle_start': cycle_start,
'cycle_end': cycle_end,
'election_url': get_election_url,
'states': sorted(constants.states.items(), key=lambda pair: pair[0]),
'constants': constants,
'districts': DISTRICTS,
'cycles': range(utils.current_cycle(), START_YEAR, -2),
})
Expand Down
234 changes: 175 additions & 59 deletions openfecwebapp/constants.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,175 @@
states = {
'AK': 'Alaska',
'AL': 'Alabama',
'AR': 'Arkansas',
'AS': 'American Samoa',
'AZ': 'Arizona',
'CA': 'California',
'CO': 'Colorado',
'CT': 'Connecticut',
'DC': 'District of Columbia',
'DE': 'Delaware',
'FL': 'Florida',
'GA': 'Georgia',
'GU': 'Guam',
'HI': 'Hawaii',
'IA': 'Iowa',
'ID': 'Idaho',
'IL': 'Illinois',
'IN': 'Indiana',
'KS': 'Kansas',
'KY': 'Kentucky',
'LA': 'Louisiana',
'MA': 'Massachusetts',
'MD': 'Maryland',
'ME': 'Maine',
'MI': 'Michigan',
'MN': 'Minnesota',
'MO': 'Missouri',
'MP': 'Northern Mariana Islands',
'MS': 'Mississippi',
'MT': 'Montana',
'NA': 'National',
'NC': 'North Carolina',
'ND': 'North Dakota',
'NE': 'Nebraska',
'NH': 'New Hampshire',
'NJ': 'New Jersey',
'NM': 'New Mexico',
'NV': 'Nevada',
'NY': 'New York',
'OH': 'Ohio',
'OK': 'Oklahoma',
'OR': 'Oregon',
'PA': 'Pennsylvania',
'PR': 'Puerto Rico',
'RI': 'Rhode Island',
'SC': 'South Carolina',
'SD': 'South Dakota',
'TN': 'Tennessee',
'TX': 'Texas',
'UT': 'Utah',
'VA': 'Virginia',
'VI': 'Virgin Islands',
'VT': 'Vermont',
'WA': 'Washington',
'WI': 'Wisconsin',
'WV': 'West Virginia',
'WY': 'Wyoming'
}
from collections import OrderedDict

states = OrderedDict([
('AK', 'Alaska'),
('AL', 'Alabama'),
('AR', 'Arkansas'),
('AS', 'American Samoa'),
('AZ', 'Arizona'),
('CA', 'California'),
('CO', 'Colorado'),
('CT', 'Connecticut'),
('DC', 'District of Columbia'),
('DE', 'Delaware'),
('FL', 'Florida'),
('GA', 'Georgia'),
('GU', 'Guam'),
('HI', 'Hawaii'),
('IA', 'Iowa'),
('ID', 'Idaho'),
('IL', 'Illinois'),
('IN', 'Indiana'),
('KS', 'Kansas'),
('KY', 'Kentucky'),
('LA', 'Louisiana'),
('MA', 'Massachusetts'),
('MD', 'Maryland'),
('ME', 'Maine'),
('MI', 'Michigan'),
('MN', 'Minnesota'),
('MO', 'Missouri'),
('MP', 'Northern Mariana Islands'),
('MS', 'Mississippi'),
('MT', 'Montana'),
('NA', 'National'),
('NC', 'North Carolina'),
('ND', 'North Dakota'),
('NE', 'Nebraska'),
('NH', 'New Hampshire'),
('NJ', 'New Jersey'),
('NM', 'New Mexico'),
('NV', 'Nevada'),
('NY', 'New York'),
('OH', 'Ohio'),
('OK', 'Oklahoma'),
('OR', 'Oregon'),
('PA', 'Pennsylvania'),
('PR', 'Puerto Rico'),
('RI', 'Rhode Island'),
('SC', 'South Carolina'),
('SD', 'South Dakota'),
('TN', 'Tennessee'),
('TX', 'Texas'),
('UT', 'Utah'),
('VA', 'Virginia'),
('VI', 'Virgin Islands'),
('VT', 'Vermont'),
('WA', 'Washington'),
('WI', 'Wisconsin'),
('WV', 'West Virginia'),
('WY', 'Wyoming'),
])

parties = OrderedDict([
('DEM', 'Democratic Party'),
('REP', 'Republican Party'),
])
parties_extended = OrderedDict([
('AIC', 'American Independent Conservative'),
('AIP', 'American Independent Party'),
('AMP', 'American Party'),
('APF', "American People's Freedom Party"),
('CIT', "Citizens' Party"),
('CMP', 'Commonwealth Party of the U.S.'),
('COM', 'Communist Party'),
('CRV', 'Conservative Party'),
('CST', 'Constitutional'),
('D/C', 'Democratic/Conservative'),
('DFL', 'Democratic-Farm-Labor'),
('FLP', 'Freedom Labor Party'),
('GRE', 'Green Party'),
('GWP', 'George Wallace Party'),
('HRP', 'Human Rights Party'),
('IAP', 'Independent American Party'),
('ICD', 'Independent Conserv. Democratic'),
('IGD', 'Industrial Government Party'),
('IND', 'Independent'),
('LAB', 'U.S. Labor Party'),
('LBL', 'Liberal Party'),
('LBR', 'Labor Party'),
('LBU', 'Liberty Union Party'),
('LFT', 'Less Federal Taxes'),
('LIB', 'Libertarian'),
('LRU', 'La Raza Unida'),
('NAP', 'Prohibition Party'),
('NDP', 'National Democratic Party'),
('NLP', 'Natural Law Party'),
('PAF', 'Peace and Freedom'),
('PFD', 'Peace Freedom Party'),
('POP', 'People Over Politics'),
('PPD', 'Protest, Progress, Dignity'),
('PPY', "People's Party"),
('REF', 'Reform Party'),
('RTL', 'Right to Life'),
('SLP', 'Socialist Labor Party'),
('SUS', 'Socialist Party U.S.A.'),
('SWP', 'Socialist Workers Party'),
('THD', 'Theo-Dem'),
('TWR', 'Taxpayers Without Representation'),
('TX', 'Taxpayers'),
('USP', "U.S. People's Party"),
])

report_types = OrderedDict([
('CA', 'COMPREHENSIVE AMEND'),
('ADJ', 'COMP ADJUST AMEND'),
('10D', 'PRE-ELECTION'),
('10G', 'PRE-GENERAL'),
('10P', 'PRE-PRIMARY'),
('10R', 'PRE-RUN-OFF'),
('10S', 'PRE-SPECIAL'),
('12C', 'Pre-Convention'),
('12G', 'Pre-General'),
('12P', 'Pre-Primary'),
('12R', 'Pre-Runoff'),
('12S', 'Pre-Special'),
('30D', 'POST-ELECTION'),
('30G', 'Post-General'),
('30P', 'POST-PRIMARY'),
('30R', 'Post-Runoff'),
('30S', 'Post-Special'),
('60D', '60 Day Post Convention of a Presidential Host Committee'),
('90D', '90 Day Post Inaugural Report by an Inaugural Committee'),
('90S', 'Supplement to a 90D Inaugural Report'),
('M1', 'JANUARY MONTHLY'),
('M2', 'February Monthly'),
('M3', 'March Monthly'),
('M4', 'April Monthly'),
('M5', 'May Monthly'),
('M6', 'June Monthly'),
('M7', 'July Monthly'),
('M8', 'August Monthly'),
('M9', 'September Monthly'),
('M10', 'October Monthly'),
('M11', 'November Monthly'),
('M12', 'December Monthly'),
('MY', 'Mid-year Report'),
('Q1', 'April Quarterly'),
('Q2', 'July Quarterly'),
('Q3', 'October Quarterly'),
('YE', 'Year-end'),
('MYE', 'Monthly Year-end'),
('TER', 'Termination Report'),
('24', '24-Hour Report'),
('48', '48-Hour Report'),
('Q2S', 'July 15 (Q2) report and Semi-annual'),
('QSA', 'Semi-Annual only'),
('QYS', 'Jan 31 Year End (YE) report and Semi-Annual'),
('QYE', 'Semi-Annual only'),
('QMS', 'July 31 Mid-Year (MY) reportand Semi-annual'),
('M7S', 'July 20 (M7) Monthly report and Semi-Annual'),
('MSA', 'Semi-Annual only'),
('MYS', 'Jan 31 Year End (MYE) report and Semi-annual'),
('MSY', 'Semi-Annual only'),
])

amendment_indicators = OrderedDict([
('N', 'New'),
('A', 'Amended'),
])
amendment_indicators_extended = OrderedDict([
('T', 'Terminated'),
('C', 'Consolidated'),
('M', 'Multi-Candidate'),
('S', 'Secondary'),
])
2 changes: 1 addition & 1 deletion templates/election-lookup.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h4 class="filter__header">New Search</h4>
<legend class="label">Or search by state and district</legend>
<select id="state" name="state">
<option value="">Select state</option>
{% for value, label in states %}
{% for value, label in constants.states.items() %}
<option value="{{ value }}">{{ label }}</option>
{% endfor %}
</select>
Expand Down
10 changes: 10 additions & 0 deletions templates/macros/filters/amendment-indicator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% import 'macros/filters/checkbox.html' as checkbox %}

{% macro amendment_indicator(options=True) %}
{{ checkbox.checkbox_dropdown(
'amendment_indicator',
'Amendment Indicator',
selected=constants.amendment_indicators,
options=constants.amendment_indicators_extended if options else {},
) }}
{% endmacro %}
35 changes: 35 additions & 0 deletions templates/macros/filters/checkbox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% macro checkbox(name, value, label) %}
<li class="dropdown__item">
<input id="{{ name }}-{{ value }}" name="{{ name }}" type="checkbox" value="{{ value }}">
<label class="dropdown__value" for="{{ name }}-{{ value }}">{{ label }}</label>
</li>
{% endmacro %}

{% macro checkbox_list(name, options, css_class='dropdown__list') %}
<ul class="{{ css_class }}">
{% for value, label in options.items() %}
{{ checkbox(name, value, label) }}
{% endfor %}
</ul>
{% endmacro %}

{% macro checkbox_options(name, options) %}
<div class="dropdown">
<button class="dropdown__button button--neutral">More</button>
<div id="{{ name }}-dropdown" class="dropdown__panel" aria-hidden="true">
{{ checkbox_list(name, options) }}
</div>
</div>
{% endmacro %}

{% macro checkbox_dropdown(name, label, selected={}, options={}) %}
<div class="filter">
<fieldset class="js-dropdown">
<legend class="label" for="{{ name }}">{{ label }}<span class="any" aria-hidden="true">(Any)</span></legend>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not actually making use of this .any span anymore, so we can remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it--updated.

{{ checkbox_list(name, selected, css_class='dropdown__selected') }}
{% if options %}
{{ checkbox_options(name, options) }}
{% endif %}
</fieldset>
</div>
{% endmacro %}
2 changes: 1 addition & 1 deletion templates/macros/filters/states.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<button class="dropdown__button button--neutral">More</button>
<div id="state-dropdown" class="dropdown__panel" aria-hidden="true">
<ul class="dropdown__list">
{% for state in states %}
{% for state in constants.states.items() %}
<li class="dropdown__item">
<input name="{{ name }}" id="state-checkbox-{{state[0]}}" type="checkbox" value="{{ state[0] }}">
<label class="dropdown__value" for="state-checkbox-{{ state[0] }}">{{ state[1] }}</label>
Expand Down
5 changes: 3 additions & 2 deletions templates/partials/filings-filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

{% import 'macros/filters/text.html' as text %}
{% import 'macros/filters/typeahead-filter.html' as typeahead %}
{% import 'macros/filters/amendment-indicator.html' as amendment %}
{% import 'macros/filters/states.html' as states %}
{% import 'macros/filters/date.html' as date %}

Expand All @@ -15,8 +16,8 @@

{{ text.field('report_year', 'Report Year') }}

{% include 'partials/filters/amendment-indicator.html' %}
{{ amendment.amendment_indicator() }}
{% include 'partials/filters/primary-general.html' %}
{% include 'partials/filters/report-type.html' %}

{% endblock %}
{% endblock %}
4 changes: 3 additions & 1 deletion templates/partials/filings-tab-candidate.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{% import 'macros/filters/amendment-indicator.html' as amendment %}

<section class="main" id="section-2" role="tabpanel" aria-hidden="true" aria-labelledby="section-2-heading">
<div class="container">
<div class="page-section__intro">
<h2 class="section-heading" id="section-4-heading">Candidate Filings {% include 'partials/cycle-select.html' %}</h2>
<div id="filters" class="meta-box filters--horizontal section__intro__left">
<form id="category-filters">
{% include 'partials/filters/amendment-indicator.html' %}
{{ amendment.amendment_indicator(options=False) }}
{% include 'partials/filters/primary-general.html' %}
{% include 'partials/filters/report-type.html' %}
</form>
Expand Down
6 changes: 4 additions & 2 deletions templates/partials/filings-tab-committee.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% import 'macros/filters/amendment-indicator.html' as amendment %}

<section class="main" id="section-4" role="tabpanel" aria-hidden="true" aria-labelledby="section-4-heading">
<div class="container">
<div class="page-section__intro">
Expand All @@ -8,7 +10,7 @@ <h2 class="section-heading" id="section-4-heading">Committee Filings {% include
</div>
<div id="filters" class="filters--horizontal">
<form id="category-filters">
{% include 'partials/filters/amendment-indicator.html' %}
{{ amendment.amendment_indicator() }}
{% include 'partials/filters/primary-general.html' %}
{% include 'partials/filters/report-type.html' %}
</form>
Expand All @@ -27,4 +29,4 @@ <h2 class="section-heading" id="section-4-heading">Committee Filings {% include
</thead>
</table>
</div>
</section>
</section>
Loading