Skip to content

7062 State Filters#7147

Open
rfultz wants to merge 14 commits into
developfrom
feature/7062-state-filters
Open

7062 State Filters#7147
rfultz wants to merge 14 commits into
developfrom
feature/7062-state-filters

Conversation

@rfultz

@rfultz rfultz commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Required reviewers

  • dev
  • SME

Impacted areas of the application

  • Combined/re-arranged the states lists in constants.py
    • Updated constants.states not to include the territories
    • Removed states_excl_territories in favor of states
    • Pulled the territories into their own OrderedDict
    • Created armed_forces OrderedDict
    • Created states_territories OrderedDict (a combination of states and territories)
    • Created states_all_contributors OrderedDict (a combination of states, territories, armed forces, and ZZ)
    • Updated election-lookup.jinja to use constants.states_territories instead of constants.states
    • Updated candidates-single.jinja to use constants.states_territories instead of constants.states
    • Updated pres-finance-map.jinja to refer to states instead of states_excl_territories
  • Changed from filters/contributor-states.jinja to filters/contributor-states.jinja
  • Added a parameter (list_type) to filters/states.jinja to use different (states, etc) lists
  • Removed filters/contributor-states.jinja
  • Updated the various templates/partials/*-filter.jinja to use states.jinja and list_type

Screenshots

They should all now look like…
image

Related PRs

None

How to test

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.20%. Comparing base (781112a) to head (bb872e0).
⚠️ Report is 12 commits behind head on develop.

Files with missing lines Patch % Lines
fec/data/views.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #7147   +/-   ##
========================================
  Coverage    79.20%   79.20%           
========================================
  Files          255      255           
  Lines         6664     6666    +2     
========================================
+ Hits          5278     5280    +2     
  Misses        1386     1386           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rfultz rfultz moved this to 👀 Ready in Website project Jun 24, 2026
@rfultz
rfultz marked this pull request as ready for review June 24, 2026 13:26

@patphongs patphongs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rfultz Good work on this. Here's some fixes needed:

  1. Need to update filters to constants.states_territories, otherwise we get an error on territories like this: http://localhost:8000/data/elections/house/pr/00/2024/

    return constants.states[value.upper()]

  2. Need to update to constants.states_territories

    <p class="callout__subtitle u-no-margin">{{ constants.states[candidate.state] }} | {{ candidate.party_full |capitalize}}</p>

  3. Need to update to constants.states_territories

    <td class="figure__value">{% if constants.states[state] %}{{ constants.states[state] }} {% endif %}{{ office_full }}{% if office_full == 'House' %} District {{ district|strip_zero_pad }}{% endif %}</td>

  4. Need to update to constants.states_territories

    View all candidates in the {% if election_year %}{{ election_year }} {% endif %}{% if constants.states[state] %}{{ constants.states[state] }}{% endif %} {% if office == 'P' %}Presidential{% else %}{{ office_full }}{% endif %}{% if office_full == 'House' %} District {{ district|strip_zero_pad }}{% endif %} election

  5. Let's go ahead and update tests here to cover assertions for state_full with territories and state lists that include territories. You'll also need to import from data the constants for these tests.

    def test_fmt_state_full(self):

Example:

assert filters.fmt_state_full('pr') == 'Puerto Rico'

New test:

def test_state_lists_include_territories(self):
        assert constants.territories['AS'] == 'American Samoa'
        assert constants.states_territories['AS'] == 'American Samoa'
        assert constants.states_all_contributors['AS'] == 'American Samoa'

Comment thread fec/data/constants.py
('ZZ', 'Foreign Countries'),
}).items(), key=operator.itemgetter(1)))
])
territories = OrderedDict([

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks to be missing on the list of territories:

('AS', 'American Samoa'),

@rfultz rfultz Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oooh, nice catch! (Looks like it's in the territories list as 'AS' and the countries list as 'ASM')

{{ office.checkbox() }}
{{ parties.checkbox() }}
{{ states.field('state') }}
{{ states.field('state', list_type='states') }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to update to list_type='states_territories'

{{ parties.checkbox() }}
{% if table_context['office'] in ['senate', 'house'] %}
{{ states.field('state') }}
{{ states.field('state', list_type='states') }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to update to list_type='states_territories'

@rfultz rfultz added this to the 32.4 milestone Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 👀 Ready

Development

Successfully merging this pull request may close these issues.

Add state equivalents to state filter of multiple data tables

2 participants