Skip to content

Conversation

@jnovinger
Copy link
Member

@jnovinger jnovinger commented Feb 13, 2025

Fixes: #18585 - filtering circuits by location

This also fixes a related issue where selected filter is not shown in the filter form.

Changes:

  • Adds CircuitFilterSet.location_id field to enable filtering with incoming GET params
  • Adds CircuitFilterForm.location_id field to enable filtering from list form
  • Adds location_id to the Location fieldset on CircuitFilterForm

This also fixes a related issue where selected filter is not shown in
the filter form.

Changes:
- Adds `CircuitFilterSet.location_id` field to enable filtering with
  incoming GET params
- Adds `CirciotFilterForm.location_id` field to enable filtering from
  list form
- Adds `location_id` to the Location fieldset on `CircuitFilterForm`
Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

Looks good @jnovinger, thanks! One ask: Could you add a simple test for the new filter under CircuitTestCase? You'll just need to create some Location instances under setUpTestData() and assign circuits to them, then essentially replicate the logic from test_site() method for location_id.

@jnovinger
Copy link
Member Author

Looks good @jnovinger, thanks! One ask: Could you add a simple test for the new filter under CircuitTestCase? You'll just need to create some Location instances under setUpTestData() and assign circuits to them, then essentially replicate the logic from test_site() method for location_id.

Test added! Thanks for the catch.

Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

Thanks @jnovinger!

@jeremystretch jeremystretch merged commit 70dddb6 into netbox-community:main Feb 18, 2025
3 checks passed
@jnovinger jnovinger deleted the 18585-filtering-circuits-by-location-not-working branch February 18, 2025 19:40
bctiemann pushed a commit that referenced this pull request Mar 6, 2025
* Fixes #18585: filtering circuits by location

This also fixes a related issue where selected filter is not shown in
the filter form.

Changes:
- Adds `CircuitFilterSet.location_id` field to enable filtering with
  incoming GET params
- Adds `CirciotFilterForm.location_id` field to enable filtering from
  list form
- Adds `location_id` to the Location fieldset on `CircuitFilterForm`

* Adds test for new CircuitFilterset.location_id filter
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filtering circuits by location not working

2 participants