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

Capture path end-to-end status in CablePath

This commit is contained in:
Jeremy Stretch
2020-10-01 16:42:57 -04:00
parent 610420c020
commit c974c5687c
5 changed files with 31 additions and 11 deletions

View File

@@ -30,7 +30,7 @@ from .nested_serializers import *
class ConnectedEndpointSerializer(ValidatedModelSerializer):
connected_endpoint_type = serializers.SerializerMethodField(read_only=True)
connected_endpoint = serializers.SerializerMethodField(read_only=True)
connection_status = ChoiceField(choices=CONNECTION_STATUS_CHOICES, read_only=True)
connection_status = serializers.SerializerMethodField(read_only=True)
def get_connected_endpoint_type(self, obj):
if obj.path is not None:
@@ -49,6 +49,13 @@ class ConnectedEndpointSerializer(ValidatedModelSerializer):
return serializer(obj.path.destination, context=context).data
return None
# TODO: Tweak the representation for this field
@swagger_serializer_method(serializer_or_field=serializers.BooleanField)
def get_connection_status(self, obj):
if obj.path is not None:
return obj.path.is_connected
return None
#
# Regions/sites