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

Drop support for split paths

This commit is contained in:
Jeremy Stretch
2020-10-01 14:16:43 -04:00
parent cd398b15d8
commit 610420c020
13 changed files with 66 additions and 97 deletions

View File

@@ -1,7 +1,6 @@
import logging
from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
@@ -256,7 +255,7 @@ class PathEndpoint(models.Model):
"""
Any object which may serve as either endpoint of a CablePath.
"""
paths = GenericRelation(
_paths = GenericRelation(
to='dcim.CablePath',
content_type_field='origin_type',
object_id_field='origin_id',
@@ -266,6 +265,15 @@ class PathEndpoint(models.Model):
class Meta:
abstract = True
@property
def path(self):
"""
Return the _complete_ CablePath associated with this origin point, if any.
"""
if not hasattr(self, '_path'):
self._path = self._paths.filter(destination_id__isnull=False).first()
return self._path
#
# Console ports