|
12 | 12 |
|
13 | 13 | from extras.choices import CustomFieldVisibilityChoices, ObjectChangeActionChoices
|
14 | 14 | from extras.utils import is_taggable, register_features
|
| 15 | +from netbox.registry import registry |
15 | 16 | from netbox.signals import post_clean
|
16 | 17 | from utilities.json import CustomFieldJSONEncoder
|
17 | 18 | from utilities.utils import serialize_object
|
@@ -388,22 +389,26 @@ def sync_data(self):
|
388 | 389 | raise NotImplementedError(f"{self.__class__} must implement a sync_data() method.")
|
389 | 390 |
|
390 | 391 |
|
391 |
| -FEATURES_MAP = ( |
392 |
| - ('custom_fields', CustomFieldsMixin), |
393 |
| - ('custom_links', CustomLinksMixin), |
394 |
| - ('export_templates', ExportTemplatesMixin), |
395 |
| - ('job_results', JobResultsMixin), |
396 |
| - ('journaling', JournalingMixin), |
397 |
| - ('synced_data', SyncedDataMixin), |
398 |
| - ('tags', TagsMixin), |
399 |
| - ('webhooks', WebhooksMixin), |
400 |
| -) |
| 392 | +FEATURES_MAP = { |
| 393 | + 'custom_fields': CustomFieldsMixin, |
| 394 | + 'custom_links': CustomLinksMixin, |
| 395 | + 'export_templates': ExportTemplatesMixin, |
| 396 | + 'job_results': JobResultsMixin, |
| 397 | + 'journaling': JournalingMixin, |
| 398 | + 'synced_data': SyncedDataMixin, |
| 399 | + 'tags': TagsMixin, |
| 400 | + 'webhooks': WebhooksMixin, |
| 401 | +} |
| 402 | + |
| 403 | +registry['model_features'].update({ |
| 404 | + feature: defaultdict(set) for feature in FEATURES_MAP.keys() |
| 405 | +}) |
401 | 406 |
|
402 | 407 |
|
403 | 408 | @receiver(class_prepared)
|
404 | 409 | def _register_features(sender, **kwargs):
|
405 | 410 | features = {
|
406 |
| - feature for feature, cls in FEATURES_MAP if issubclass(sender, cls) |
| 411 | + feature for feature, cls in FEATURES_MAP.items() if issubclass(sender, cls) |
407 | 412 | }
|
408 | 413 | register_features(sender, features)
|
409 | 414 |
|
|
0 commit comments