mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #13426: Register all model features in the registry
This commit is contained in:
@ -525,11 +525,20 @@ class SyncedDataMixin(models.Model):
|
|||||||
raise NotImplementedError(f"{self.__class__} must implement a sync_data() method.")
|
raise NotImplementedError(f"{self.__class__} must implement a sync_data() method.")
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Feature registration
|
||||||
|
#
|
||||||
|
|
||||||
FEATURES_MAP = {
|
FEATURES_MAP = {
|
||||||
'bookmarks': BookmarksMixin,
|
'bookmarks': BookmarksMixin,
|
||||||
|
'change_logging': ChangeLoggingMixin,
|
||||||
|
'cloning': CloningMixin,
|
||||||
|
'contacts': ContactsMixin,
|
||||||
'custom_fields': CustomFieldsMixin,
|
'custom_fields': CustomFieldsMixin,
|
||||||
'custom_links': CustomLinksMixin,
|
'custom_links': CustomLinksMixin,
|
||||||
|
'custom_validation': CustomValidationMixin,
|
||||||
'export_templates': ExportTemplatesMixin,
|
'export_templates': ExportTemplatesMixin,
|
||||||
|
'image_attachments': ImageAttachmentsMixin,
|
||||||
'jobs': JobsMixin,
|
'jobs': JobsMixin,
|
||||||
'journaling': JournalingMixin,
|
'journaling': JournalingMixin,
|
||||||
'synced_data': SyncedDataMixin,
|
'synced_data': SyncedDataMixin,
|
||||||
@ -544,12 +553,13 @@ registry['model_features'].update({
|
|||||||
|
|
||||||
@receiver(class_prepared)
|
@receiver(class_prepared)
|
||||||
def _register_features(sender, **kwargs):
|
def _register_features(sender, **kwargs):
|
||||||
|
# Record each applicable feature for the model in the registry
|
||||||
features = {
|
features = {
|
||||||
feature for feature, cls in FEATURES_MAP.items() if issubclass(sender, cls)
|
feature for feature, cls in FEATURES_MAP.items() if issubclass(sender, cls)
|
||||||
}
|
}
|
||||||
register_features(sender, features)
|
register_features(sender, features)
|
||||||
|
|
||||||
# Feature view registration
|
# Register applicable feature views for the model
|
||||||
if issubclass(sender, JournalingMixin):
|
if issubclass(sender, JournalingMixin):
|
||||||
register_model_view(
|
register_model_view(
|
||||||
sender,
|
sender,
|
||||||
|
Reference in New Issue
Block a user