mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 08:25:17 -06:00
10595 fix merge conflicts
This commit is contained in:
commit
4ac98a2c26
@ -18,6 +18,7 @@ A new `PluginMenu` class has been introduced, which enables a plugin to inject a
|
||||
### Enhancements
|
||||
|
||||
* [#9249](https://github.com/netbox-community/netbox/issues/9249) - Device and virtual machine names are no longer case-sensitive
|
||||
* [#9478](https://github.com/netbox-community/netbox/issues/9478) - Add `link_peers` field to GraphQL types for cabled objects
|
||||
* [#9654](https://github.com/netbox-community/netbox/issues/9654) - Add `weight` field to racks, device types, and module types
|
||||
* [#9892](https://github.com/netbox-community/netbox/issues/9892) - Add optional `name` field for FHRP groups
|
||||
* [#10348](https://github.com/netbox-community/netbox/issues/10348) - Add decimal custom field type
|
||||
@ -51,3 +52,4 @@ A new `PluginMenu` class has been introduced, which enables a plugin to inject a
|
||||
### GraphQL API Changes
|
||||
|
||||
* All object types now include a `display` field
|
||||
* All cabled object types now include a `link_peers` field
|
||||
|
@ -37,6 +37,42 @@ from dcim.models import (
|
||||
)
|
||||
|
||||
|
||||
class LinkPeerType(graphene.Union):
|
||||
class Meta:
|
||||
types = (
|
||||
CircuitTerminationType,
|
||||
ConsolePortType,
|
||||
ConsoleServerPortType,
|
||||
FrontPortType,
|
||||
InterfaceType,
|
||||
PowerFeedType,
|
||||
PowerOutletType,
|
||||
PowerPortType,
|
||||
RearPortType,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def resolve_type(cls, instance, info):
|
||||
if type(instance) == CircuitTermination:
|
||||
return CircuitTerminationType
|
||||
if type(instance) == ConsolePortType:
|
||||
return ConsolePortType
|
||||
if type(instance) == ConsoleServerPort:
|
||||
return ConsoleServerPortType
|
||||
if type(instance) == FrontPort:
|
||||
return FrontPortType
|
||||
if type(instance) == Interface:
|
||||
return InterfaceType
|
||||
if type(instance) == PowerFeed:
|
||||
return PowerFeedType
|
||||
if type(instance) == PowerOutlet:
|
||||
return PowerOutletType
|
||||
if type(instance) == PowerPort:
|
||||
return PowerPortType
|
||||
if type(instance) == RearPort:
|
||||
return RearPortType
|
||||
|
||||
|
||||
class CableTerminationTerminationType(graphene.Union):
|
||||
class Meta:
|
||||
types = (
|
||||
|
@ -1,5 +1,12 @@
|
||||
import graphene
|
||||
|
||||
|
||||
class CabledObjectMixin:
|
||||
link_peers = graphene.List('dcim.graphql.gfk_mixins.LinkPeerType')
|
||||
|
||||
def resolve_cable_end(self, info):
|
||||
# Handle empty values
|
||||
return self.cable_end or None
|
||||
|
||||
def resolve_link_peers(self, info):
|
||||
return self.link_peers
|
||||
|
@ -1,10 +1,14 @@
|
||||
import graphene
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from extras.graphql.mixins import (
|
||||
ChangelogMixin,
|
||||
CustomFieldsMixin,
|
||||
JournalEntriesMixin,
|
||||
TagsMixin,
|
||||
)
|
||||
from graphene_django import DjangoObjectType
|
||||
|
||||
from extras.graphql.mixins import ChangelogMixin, CustomFieldsMixin, JournalEntriesMixin, TagsMixin
|
||||
|
||||
__all__ = (
|
||||
'BaseObjectType',
|
||||
'ObjectType',
|
||||
@ -22,9 +26,7 @@ class BaseObjectType(DjangoObjectType):
|
||||
Base GraphQL object type for all NetBox objects. Restricts the model queryset to enforce object permissions.
|
||||
"""
|
||||
display = graphene.String()
|
||||
|
||||
def resolve_display(parent, info, **kwargs):
|
||||
return str(parent)
|
||||
class_type = graphene.String()
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
@ -34,6 +36,12 @@ class BaseObjectType(DjangoObjectType):
|
||||
# Enforce object permissions on the queryset
|
||||
return queryset.restrict(info.context.user, 'view')
|
||||
|
||||
def resolve_display(parent, info, **kwargs):
|
||||
return str(parent)
|
||||
|
||||
def resolve_class_type(parent, info, **kwargs):
|
||||
return parent.__class__.__name__
|
||||
|
||||
|
||||
class ObjectType(
|
||||
ChangelogMixin,
|
||||
|
@ -453,6 +453,9 @@ class APIViewTestCases:
|
||||
elif inspect.isclass(field.type) and issubclass(field.type, GQLUnion):
|
||||
# Union types dont' have an id or consistent values
|
||||
continue
|
||||
elif type(field.type) is GQLList and inspect.isclass(field.type.of_type) and issubclass(field.type.of_type, GQLUnion):
|
||||
# Union types dont' have an id or consistent values
|
||||
continue
|
||||
elif type(field.type) is GQLList and field_name != 'choices':
|
||||
# TODO: Come up with something more elegant
|
||||
# Temporary hack to support automated testing of reverse generic relations
|
||||
|
Loading…
Reference in New Issue
Block a user