mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-13 16:47:34 -06:00
Compare commits
6 Commits
6f7e9f8692
...
f22ebcb539
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f22ebcb539 | ||
![]() |
9c2cd66162 | ||
![]() |
5f58fe1eb5 | ||
![]() |
5fb81e9943 | ||
![]() |
e8891f770c | ||
![]() |
4739f27c14 |
@ -6,7 +6,7 @@
|
|||||||
<a href="https://github.com/netbox-community/netbox/graphs/contributors"><img src="https://img.shields.io/github/contributors/netbox-community/netbox?color=blue" alt="Contributors" /></a>
|
<a href="https://github.com/netbox-community/netbox/graphs/contributors"><img src="https://img.shields.io/github/contributors/netbox-community/netbox?color=blue" alt="Contributors" /></a>
|
||||||
<a href="https://github.com/netbox-community/netbox/stargazers"><img src="https://img.shields.io/github/stars/netbox-community/netbox?style=flat" alt="GitHub stars" /></a>
|
<a href="https://github.com/netbox-community/netbox/stargazers"><img src="https://img.shields.io/github/stars/netbox-community/netbox?style=flat" alt="GitHub stars" /></a>
|
||||||
<a href="https://explore.transifex.com/netbox-community/netbox/"><img src="https://img.shields.io/badge/languages-15-blue" alt="Languages supported" /></a>
|
<a href="https://explore.transifex.com/netbox-community/netbox/"><img src="https://img.shields.io/badge/languages-15-blue" alt="Languages supported" /></a>
|
||||||
<a href="https://github.com/netbox-community/netbox/actions/workflows/ci.yml"><img src="https://github.com/netbox-community/netbox/workflows/CI/badge.svg?branch=main" alt="CI status" /></a>
|
<a href="https://github.com/netbox-community/netbox/actions/workflows/ci.yml"><img src="https://github.com/netbox-community/netbox/actions/workflows/ci.yml/badge.svg" alt="CI status" /></a>
|
||||||
<p>
|
<p>
|
||||||
<strong><a href="https://netboxlabs.com/community/">NetBox Community</a></strong> |
|
<strong><a href="https://netboxlabs.com/community/">NetBox Community</a></strong> |
|
||||||
<strong><a href="https://netboxlabs.com/netbox-cloud/">NetBox Cloud</a></strong> |
|
<strong><a href="https://netboxlabs.com/netbox-cloud/">NetBox Cloud</a></strong> |
|
||||||
|
@ -220,6 +220,7 @@ class Cable(PrimaryModel):
|
|||||||
b_terminations = {ct.termination: ct for ct in self.terminations.filter(cable_end='B')}
|
b_terminations = {ct.termination: ct for ct in self.terminations.filter(cable_end='B')}
|
||||||
|
|
||||||
# Delete stale CableTerminations
|
# Delete stale CableTerminations
|
||||||
|
|
||||||
if self._terminations_modified:
|
if self._terminations_modified:
|
||||||
for termination, ct in a_terminations.items():
|
for termination, ct in a_terminations.items():
|
||||||
if termination.pk and termination not in self.a_terminations:
|
if termination.pk and termination not in self.a_terminations:
|
||||||
@ -312,6 +313,12 @@ class CableTermination(ChangeLoggedModel):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'Cable {self.cable} to {self.termination}'
|
return f'Cable {self.cable} to {self.termination}'
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self._orig_cable = self.__dict__.get('cable')
|
||||||
|
self._orig_cable_end = self.__dict__.get('cable_end')
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
@ -349,6 +356,7 @@ class CableTermination(ChangeLoggedModel):
|
|||||||
|
|
||||||
# Cache objects associated with the terminating object (for filtering)
|
# Cache objects associated with the terminating object (for filtering)
|
||||||
self.cache_related_objects()
|
self.cache_related_objects()
|
||||||
|
created = self.pk is None
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
@ -359,6 +367,28 @@ class CableTermination(ChangeLoggedModel):
|
|||||||
termination.cable_end = self.cable_end
|
termination.cable_end = self.cable_end
|
||||||
termination.save()
|
termination.save()
|
||||||
|
|
||||||
|
# figure out which cable terminations changed
|
||||||
|
if not created:
|
||||||
|
update_cable_termination = False
|
||||||
|
update_orig_cable_termination = False
|
||||||
|
|
||||||
|
if self._orig_cable and self._orig_cable != self.cable:
|
||||||
|
update_cable_termination = True
|
||||||
|
update_orig_cable_termination = True
|
||||||
|
elif self._orig_cable_end and self._orig_cable_end != self.cable_end:
|
||||||
|
update_cable_termination = True
|
||||||
|
|
||||||
|
if update_cable_termination:
|
||||||
|
self.cable._terminations_modified = True
|
||||||
|
trace_paths.send(Cable, instance=self.cable, created=False)
|
||||||
|
|
||||||
|
if update_orig_cable_termination:
|
||||||
|
self._orig_cable._terminations_modified = True
|
||||||
|
trace_paths.send(Cable, instance=self._orig_cable, created=False)
|
||||||
|
|
||||||
|
self._orig_cable_end = self.cable_end
|
||||||
|
self._orig_cable = self.cable
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
|
|
||||||
# Delete the cable association on the terminating object
|
# Delete the cable association on the terminating object
|
||||||
@ -369,6 +399,7 @@ class CableTermination(ChangeLoggedModel):
|
|||||||
termination.save()
|
termination.save()
|
||||||
|
|
||||||
super().delete(*args, **kwargs)
|
super().delete(*args, **kwargs)
|
||||||
|
trace_paths.send(Cable, instance=self.cable, created=False)
|
||||||
|
|
||||||
def cache_related_objects(self):
|
def cache_related_objects(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user