mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-15 08:12:18 -06:00
This commit is contained in:
@@ -131,6 +131,19 @@ class DataSource(JobsMixin, PrimaryModel):
|
|||||||
'source_url': "URLs for local sources must start with file:// (or specify no scheme)"
|
'source_url': "URLs for local sources must start with file:// (or specify no scheme)"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
|
||||||
|
# If recurring sync is disabled for an existing DataSource, clear any pending sync jobs for it and reset its
|
||||||
|
# "queued" status
|
||||||
|
if not self._state.adding and not self.sync_interval:
|
||||||
|
self.jobs.filter(status=JobStatusChoices.STATUS_PENDING).delete()
|
||||||
|
if self.status == DataSourceStatusChoices.QUEUED and self.last_synced:
|
||||||
|
self.status = DataSourceStatusChoices.COMPLETED
|
||||||
|
elif self.status == DataSourceStatusChoices.QUEUED:
|
||||||
|
self.status = DataSourceStatusChoices.NEW
|
||||||
|
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def to_objectchange(self, action):
|
def to_objectchange(self, action):
|
||||||
objectchange = super().to_objectchange(action)
|
objectchange = super().to_objectchange(action)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user