mirror of
https://github.com/netbox-community/netbox.git
synced 2026-02-26 18:47:38 +01:00
Compare commits
3 Commits
feature
...
21524-invl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aafe20a737 | ||
|
|
74326edc20 | ||
|
|
2ef21f7097 |
@@ -84,6 +84,9 @@ class CablePathSerializer(serializers.ModelSerializer):
|
||||
def get_path(self, obj):
|
||||
ret = []
|
||||
for nodes in obj.path_objects:
|
||||
if not nodes:
|
||||
# The path contains an invalid object
|
||||
return []
|
||||
serializer = get_serializer_for_model(nodes[0])
|
||||
context = {'request': self.context['request']}
|
||||
ret.append(serializer(nodes, nested=True, many=True, context=context).data)
|
||||
|
||||
@@ -921,6 +921,7 @@ class InterfaceTypeChoices(ChoiceSet):
|
||||
# 10 Gbps Ethernet
|
||||
TYPE_10GE_BR_D = '10gbase-br-d'
|
||||
TYPE_10GE_BR_U = '10gbase-br-u'
|
||||
TYPE_10GE_CU = '10gbase-cu'
|
||||
TYPE_10GE_CX4 = '10gbase-cx4'
|
||||
TYPE_10GE_ER = '10gbase-er'
|
||||
TYPE_10GE_LR = '10gbase-lr'
|
||||
@@ -943,6 +944,7 @@ class InterfaceTypeChoices(ChoiceSet):
|
||||
TYPE_40GE_FR4 = '40gbase-fr4'
|
||||
TYPE_40GE_LR4 = '40gbase-lr4'
|
||||
TYPE_40GE_SR4 = '40gbase-sr4'
|
||||
TYPE_40GE_SR4_BD = '40gbase-sr4-bd'
|
||||
|
||||
# 50 Gbps Ethernet
|
||||
TYPE_50GE_CR = '50gbase-cr'
|
||||
@@ -1192,6 +1194,7 @@ class InterfaceTypeChoices(ChoiceSet):
|
||||
(
|
||||
(TYPE_10GE_BR_D, '10GBASE-BR-D (10GE BiDi Down)'),
|
||||
(TYPE_10GE_BR_U, '10GBASE-BR-U (10GE BiDi Up)'),
|
||||
(TYPE_10GE_CU, '10GBASE-CU (10GE DAC Passive Twinax)'),
|
||||
(TYPE_10GE_CX4, '10GBASE-CX4 (10GE DAC)'),
|
||||
(TYPE_10GE_ER, '10GBASE-ER (10GE)'),
|
||||
(TYPE_10GE_LR, '10GBASE-LR (10GE)'),
|
||||
@@ -1220,6 +1223,7 @@ class InterfaceTypeChoices(ChoiceSet):
|
||||
(TYPE_40GE_FR4, '40GBASE-FR4 (40GE)'),
|
||||
(TYPE_40GE_LR4, '40GBASE-LR4 (40GE)'),
|
||||
(TYPE_40GE_SR4, '40GBASE-SR4 (40GE)'),
|
||||
(TYPE_40GE_SR4_BD, '40GBASE-SR4 (40GE BiDi)'),
|
||||
)
|
||||
),
|
||||
(
|
||||
|
||||
@@ -22,7 +22,19 @@ if TYPE_CHECKING:
|
||||
@strawberry.type
|
||||
class ConfigContextMixin:
|
||||
|
||||
@strawberry_django.field
|
||||
@classmethod
|
||||
def get_queryset(cls, queryset, info: Info, **kwargs):
|
||||
queryset = super().get_queryset(queryset, info, **kwargs)
|
||||
|
||||
# If `config_context` is requested, call annotate_config_context_data() on the queryset
|
||||
selected = {f.name for f in info.selected_fields[0].selections}
|
||||
if 'config_context' in selected and hasattr(queryset, 'annotate_config_context_data'):
|
||||
return queryset.annotate_config_context_data()
|
||||
|
||||
return queryset
|
||||
|
||||
# Ensure `local_context_data` is fetched when `config_context` is requested
|
||||
@strawberry_django.field(only=['local_context_data'])
|
||||
def config_context(self) -> strawberry.scalars.JSON:
|
||||
return self.get_config_context()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user