Skip to content

Filter fields2#437

Draft
arthanson wants to merge 17 commits intomainfrom
filter-fields2
Draft

Filter fields2#437
arthanson wants to merge 17 commits intomainfrom
filter-fields2

Conversation

@arthanson
Copy link
Copy Markdown
Contributor

Fixes: #296

From @ifoughal original PR: #365 - added tests and cleanup.

Pull request overview

This pull request adds dynamic filtering capabilities for custom object type fields, allowing users to filter custom objects based on their field values. The changes introduce a flexible filter specification system that maps each custom field type to an appropriate django-filter Filter class.

Changes:

  • Introduced a FilterSpec dataclass and field type-to-filter mapping system in filtersets.py
  • Added build_filter_for_field function to dynamically generate filters for custom fields
  • Implemented get_filterform_field methods for Object and MultiObject field types in field_types.py
  • Changed decimal field precision from 2 to 4 decimal places
  • Fixed incorrect module name from "database.filtersets" to "netbox_custom_objects.filtersets"

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
netbox_custom_objects/filtersets.py Adds FilterSpec dataclass, FIELD_TYPE_FILTERS mapping, and build_filter_for_field function to dynamically create filters for custom fields; fixes module name bug
netbox_custom_objects/field_types.py Implements get_filterform_field methods for DecimalFieldType, ObjectFieldType, and MultiObjectFieldType; increases decimal precision from 2 to 4 places

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add filter by attributed for custom-object-types

3 participants