1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #2571: Enforce deletion of attached cable when deleting a termination point

This commit is contained in:
Jeremy Stretch
2018-11-08 12:15:56 -05:00
parent bb5432de7d
commit 3e92aa9fe7
4 changed files with 70 additions and 4 deletions

View File

@@ -73,6 +73,18 @@ class CableTermination(models.Model):
null=True
)
# Generic relations to Cable. These ensure that an attached Cable is deleted if the terminated object is deleted.
_cabled_as_a = GenericRelation(
to='dcim.Cable',
content_type_field='termination_a_type',
object_id_field='termination_a_id'
)
_cabled_as_b = GenericRelation(
to='dcim.Cable',
content_type_field='termination_b_type',
object_id_field='termination_b_id'
)
class Meta:
abstract = True