mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Add image_attachments to Device, Location, Rack, Site
This commit is contained in:
parent
0df67dbc12
commit
8ad958708f
@ -1,4 +1,5 @@
|
|||||||
from dcim import filtersets, models
|
from dcim import filtersets, models
|
||||||
|
from extras.graphql.mixins import ImageAttachmentsMixin
|
||||||
from ipam.graphql.mixins import IPAddressesMixin
|
from ipam.graphql.mixins import IPAddressesMixin
|
||||||
from netbox.graphql.types import BaseObjectType, ObjectType, TaggedObjectType
|
from netbox.graphql.types import BaseObjectType, ObjectType, TaggedObjectType
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ class ConsoleServerPortTemplateType(BaseObjectType):
|
|||||||
return self.type or None
|
return self.type or None
|
||||||
|
|
||||||
|
|
||||||
class DeviceType(TaggedObjectType):
|
class DeviceType(ImageAttachmentsMixin, TaggedObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Device
|
model = models.Device
|
||||||
@ -186,7 +187,7 @@ class InventoryItemType(TaggedObjectType):
|
|||||||
filterset_class = filtersets.InventoryItemFilterSet
|
filterset_class = filtersets.InventoryItemFilterSet
|
||||||
|
|
||||||
|
|
||||||
class LocationType(ObjectType):
|
class LocationType(ImageAttachmentsMixin, ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Location
|
model = models.Location
|
||||||
@ -276,7 +277,7 @@ class PowerPortTemplateType(BaseObjectType):
|
|||||||
return self.type or None
|
return self.type or None
|
||||||
|
|
||||||
|
|
||||||
class RackType(TaggedObjectType):
|
class RackType(ImageAttachmentsMixin, TaggedObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Rack
|
model = models.Rack
|
||||||
@ -330,7 +331,7 @@ class RegionType(ObjectType):
|
|||||||
filterset_class = filtersets.RegionFilterSet
|
filterset_class = filtersets.RegionFilterSet
|
||||||
|
|
||||||
|
|
||||||
class SiteType(TaggedObjectType):
|
class SiteType(ImageAttachmentsMixin, TaggedObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Site
|
model = models.Site
|
||||||
|
12
netbox/extras/graphql/mixins.py
Normal file
12
netbox/extras/graphql/mixins.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import graphene
|
||||||
|
|
||||||
|
__all__ = (
|
||||||
|
'ImageAttachmentsMixin',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ImageAttachmentsMixin:
|
||||||
|
image_attachments = graphene.List('extras.graphql.types.ImageAttachmentType')
|
||||||
|
|
||||||
|
def resolve_image_attachments(self, info):
|
||||||
|
return self.images.restrict(info.context.user, 'view')
|
Loading…
Reference in New Issue
Block a user