mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 16:26:09 -06:00
9478 add class_type
This commit is contained in:
parent
7d976f0477
commit
5de5422ad7
@ -1,8 +1,13 @@
|
|||||||
|
import graphene
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
from extras.graphql.mixins import (
|
||||||
|
ChangelogMixin,
|
||||||
|
CustomFieldsMixin,
|
||||||
|
JournalEntriesMixin,
|
||||||
|
TagsMixin,
|
||||||
|
)
|
||||||
from graphene_django import DjangoObjectType
|
from graphene_django import DjangoObjectType
|
||||||
|
|
||||||
from extras.graphql.mixins import ChangelogMixin, CustomFieldsMixin, JournalEntriesMixin, TagsMixin
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'BaseObjectType',
|
'BaseObjectType',
|
||||||
'ObjectType',
|
'ObjectType',
|
||||||
@ -19,6 +24,8 @@ class BaseObjectType(DjangoObjectType):
|
|||||||
"""
|
"""
|
||||||
Base GraphQL object type for all NetBox objects. Restricts the model queryset to enforce object permissions.
|
Base GraphQL object type for all NetBox objects. Restricts the model queryset to enforce object permissions.
|
||||||
"""
|
"""
|
||||||
|
class_type = graphene.String()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
@ -27,6 +34,9 @@ class BaseObjectType(DjangoObjectType):
|
|||||||
# Enforce object permissions on the queryset
|
# Enforce object permissions on the queryset
|
||||||
return queryset.restrict(info.context.user, 'view')
|
return queryset.restrict(info.context.user, 'view')
|
||||||
|
|
||||||
|
def resolve_class_type(parent, info, **kwargs):
|
||||||
|
return parent.__class__.__name__
|
||||||
|
|
||||||
|
|
||||||
class ObjectType(
|
class ObjectType(
|
||||||
ChangelogMixin,
|
ChangelogMixin,
|
||||||
|
Loading…
Reference in New Issue
Block a user