Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixin classes renaming and filter code reorganization #2798

Merged
merged 11 commits into from Nov 16, 2022

Conversation

glennmatthews
Copy link
Contributor

Closes: #2779

What's Changed

Groundwork for #2723 and 2.0.

  • nautobot.dcim.filter_mixins becomes nautobot.dcim.filters.mixins submodule
  • Create nautobot.extras.filters.mixins and nautobot.extras.filters.customfields submodules
  • Create nautobot.tenancy.filters.mixins submodule
  • Rename a bunch of mixin classes for consistency and clarity, with backwards-compatibility aliases as appropriate:
Former Name New Name
nautobot.dcim.filters.CableTerminationFilterSet nautobot.dcim.filters.mixins.CableTerminationModelFilterSetMixin
nautobot.dcim.api.serializers.CableTerminationSerializer nautobot.dcim.api.serializers.CableTerminationModelSerializerMixin
nautobot.dcim.api.serializers.ConnectedEndpointSerializer nautobot.dcim.api.serializers.PathEndpointModelSerializerMixin
nautobot.dcim.filters.ConnectionFilterSet nautobot.dcim.filters.mixins.ConnectionFilterSetMixin
nautobot.extras.filters.CreatedUpdatedFilterSet nautobot.extras.filters.mixins.CreatedUpdatedModelFilterSetMixin
nautobot.extras.filters.CustomFieldModelFilterSet nautobot.extras.filters.mixins.CustomFieldModelFilterSetMixin
nautobot.extras.api.customfields.CustomFieldModelSerializer nautobot.extras.api.customfields.CustomFieldModelSerializerMixin
nautobot.dcim.filters.DeviceComponentFilterSet nautobot.dcim.filters.mixins.DeviceComponentModelFilterSetMixin
nautobot.dcim.filters.DeviceTypeComponentFilterSet nautobot.dcim.filters.mixins.DeviceComponentTemplateModelFilterSetMixin
nautobot.extras.filters.LocalContextFilterSet nautobot.extras.filters.mixins.LocalContextModelFilterSetMixin
nautobot.dcim.filters.PathEndpointFilterSet nautobot.dcim.filters.mixins.PathEndpointModelFilterSetMixin
nautobot.extras.filters.RelationshipModelFilterSet nautobot.extras.filters.mixins.RelationshipModelFilterSetMixin
nautobot.extras.api.serializers.TaggedObjectSerializer nautobot.extras.api.serializers.TaggedModelSerializerMixin
nautobot.tenancy.filters.TenancyFilterSet nautobot.tenancy.filters.mixins.TenancyModelFilterSetMixin

TODO

  • Explanation of Change(s)
  • Added change log fragment(s) (for more information see the documentation)
  • n/a Attached Screenshots, Payload Example
  • n/a Unit, Integration Tests
  • Documentation Updates (when adding/changing features)
  • n/a Example Plugin Updates (when adding/changing features)
  • n/a Outline Remaining Work, Constraints from Design

@bryanculver
Copy link
Member

🥲

Copy link
Contributor

@HanlinMiao HanlinMiao left a comment

Choose a reason for hiding this comment

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

Thanks for the hardwork, LGTM!

@glennmatthews
Copy link
Contributor Author

I think we should hold off on this one until after we cut 1.5.1 - would like to get this as well as the apps-API first pass for #2723 into the same release.

Copy link
Contributor

@jathanism jathanism left a comment

Choose a reason for hiding this comment

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

This is a nice step forward. I'm wondering if we should be more explicit about API serializer mixins and having those also be delineated in their own foo.api.serializers.mixins submodule, or if we think their use-case is slightly different?

It may be less of a concern seeing as serializers aren't required for models/forms at this time?

nautobot/dcim/api/serializers.py Show resolved Hide resolved
nautobot/dcim/api/serializers.py Show resolved Hide resolved
@glennmatthews glennmatthews marked this pull request as draft November 14, 2022 20:44
@glennmatthews glennmatthews marked this pull request as ready for review November 15, 2022 20:12
@glennmatthews
Copy link
Contributor Author

Per our discussion this morning, I've added a new LOG_DEPRECATION_WARNINGS settings flag (defaulting to False for now) to control the emission of warning logs when a DeprecationWarning is raised.

Copy link
Contributor

@jathanism jathanism left a comment

Choose a reason for hiding this comment

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

nautobot/docs/release-notes/version-1.5.md Outdated Show resolved Hide resolved
@@ -110,3 +110,9 @@ def get_field_names(self, declared_fields, info):
self.extend_field_names(fields, "custom_fields")
self.extend_field_names(fields, "computed_fields", opt_in_only=True)
return fields


# TODO: remove in 2.2
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we should go ahead and backlog these and attach the issue(s) to the 2.2 milestone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Opened #2850.

Co-authored-by: Jathan McCollum <jathan@gmail.com>
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.

Rename mixins to be suffixed with Mixin and mark old names as deprecated.
4 participants