From 4e8a3e0a6f787d7ebb7bd718fcc5b3d675af1a6f Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 9 Aug 2023 10:27:10 -0400 Subject: [PATCH] Closes #13426: Register all model features in the registry --- netbox/netbox/models/features.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/netbox/netbox/models/features.py b/netbox/netbox/models/features.py index 08693850f..f0ab29123 100644 --- a/netbox/netbox/models/features.py +++ b/netbox/netbox/models/features.py @@ -525,11 +525,20 @@ class SyncedDataMixin(models.Model): raise NotImplementedError(f"{self.__class__} must implement a sync_data() method.") +# +# Feature registration +# + FEATURES_MAP = { 'bookmarks': BookmarksMixin, + 'change_logging': ChangeLoggingMixin, + 'cloning': CloningMixin, + 'contacts': ContactsMixin, 'custom_fields': CustomFieldsMixin, 'custom_links': CustomLinksMixin, + 'custom_validation': CustomValidationMixin, 'export_templates': ExportTemplatesMixin, + 'image_attachments': ImageAttachmentsMixin, 'jobs': JobsMixin, 'journaling': JournalingMixin, 'synced_data': SyncedDataMixin, @@ -544,12 +553,13 @@ registry['model_features'].update({ @receiver(class_prepared) def _register_features(sender, **kwargs): + # Record each applicable feature for the model in the registry features = { feature for feature, cls in FEATURES_MAP.items() if issubclass(sender, cls) } register_features(sender, features) - # Feature view registration + # Register applicable feature views for the model if issubclass(sender, JournalingMixin): register_model_view( sender,