mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Return no terminations if the cable is unsaved
This commit is contained in:
committed by
Jeremy Stretch
parent
ce9933da85
commit
f7b85ab941
@ -112,6 +112,10 @@ class Cable(PrimaryModel):
|
|||||||
def a_terminations(self):
|
def a_terminations(self):
|
||||||
if hasattr(self, '_a_terminations'):
|
if hasattr(self, '_a_terminations'):
|
||||||
return self._a_terminations
|
return self._a_terminations
|
||||||
|
|
||||||
|
if not self.pk:
|
||||||
|
return []
|
||||||
|
|
||||||
# Query self.terminations.all() to leverage cached results
|
# Query self.terminations.all() to leverage cached results
|
||||||
return [
|
return [
|
||||||
ct.termination for ct in self.terminations.all() if ct.cable_end == CableEndChoices.SIDE_A
|
ct.termination for ct in self.terminations.all() if ct.cable_end == CableEndChoices.SIDE_A
|
||||||
@ -127,6 +131,10 @@ class Cable(PrimaryModel):
|
|||||||
def b_terminations(self):
|
def b_terminations(self):
|
||||||
if hasattr(self, '_b_terminations'):
|
if hasattr(self, '_b_terminations'):
|
||||||
return self._b_terminations
|
return self._b_terminations
|
||||||
|
|
||||||
|
if not self.pk:
|
||||||
|
return []
|
||||||
|
|
||||||
# Query self.terminations.all() to leverage cached results
|
# Query self.terminations.all() to leverage cached results
|
||||||
return [
|
return [
|
||||||
ct.termination for ct in self.terminations.all() if ct.cable_end == CableEndChoices.SIDE_B
|
ct.termination for ct in self.terminations.all() if ct.cable_end == CableEndChoices.SIDE_B
|
||||||
|
Reference in New Issue
Block a user