mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
* Closes #12129: Enable automatic synchronization of objects when DataFiles are updated * Cleanup
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import django.dispatch
|
||||
from django.dispatch import Signal, receiver
|
||||
|
||||
__all__ = (
|
||||
'post_sync',
|
||||
@ -6,5 +6,16 @@ __all__ = (
|
||||
)
|
||||
|
||||
# DataSource signals
|
||||
pre_sync = django.dispatch.Signal()
|
||||
post_sync = django.dispatch.Signal()
|
||||
pre_sync = Signal()
|
||||
post_sync = Signal()
|
||||
|
||||
|
||||
@receiver(post_sync)
|
||||
def auto_sync(instance, **kwargs):
|
||||
"""
|
||||
Automatically synchronize any DataFiles with AutoSyncRecords after synchronizing a DataSource.
|
||||
"""
|
||||
from .models import AutoSyncRecord
|
||||
|
||||
for autosync in AutoSyncRecord.objects.filter(datafile__source=instance).prefetch_related('object'):
|
||||
autosync.object.sync(save=True)
|
||||
|
Reference in New Issue
Block a user