9856 update imports

This commit is contained in:
Arthur 2024-01-03 17:20:13 -08:00
parent de2d9edbd4
commit 7a222a6501
5 changed files with 36 additions and 31 deletions

View File

@ -1,4 +1,5 @@
import strawberry
import strawberry_django
from circuits import filtersets, models
from dcim.graphql.mixins import CabledObjectMixin
@ -17,7 +18,7 @@ __all__ = (
)
@strawberry.django.type(
@strawberry_django.type(
models.Provider,
fields='__all__',
filters=ProviderFilter
@ -26,7 +27,7 @@ class ProviderType(NetBoxObjectType, ContactsMixin):
pass
@strawberry.django.type(
@strawberry_django.type(
models.ProviderAccount,
fields='__all__',
filters=ProviderAccountFilter
@ -35,7 +36,7 @@ class ProviderAccountType(NetBoxObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.ProviderNetwork,
fields='__all__',
filters=ProviderNetworkFilter
@ -44,7 +45,7 @@ class ProviderNetworkType(NetBoxObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.CircuitTermination,
fields='__all__',
filters=CircuitTerminationFilter
@ -53,7 +54,7 @@ class CircuitTerminationType(CustomFieldsMixin, TagsMixin, CabledObjectMixin, Ob
pass
@strawberry.django.type(
@strawberry_django.type(
models.Circuit,
fields='__all__',
filters=CircuitFilter
@ -62,7 +63,7 @@ class CircuitType(NetBoxObjectType, ContactsMixin):
provider: ProviderType
@strawberry.django.type(
@strawberry_django.type(
models.CircuitType,
# fields='__all__',
exclude=['color',], # bug - remove color from exclude

View File

@ -1,4 +1,5 @@
import strawberry
import strawberry_django
from typing import TYPE_CHECKING, Annotated, List
from django.contrib.contenttypes.models import ContentType
@ -22,7 +23,7 @@ if TYPE_CHECKING:
@strawberry.type
class ChangelogMixin:
@strawberry.django.field
@strawberry_django.field
def changelog(self) -> List[Annotated["ObjectChangeType", strawberry.lazy('.types')]]:
content_type = ContentType.objects.get_for_model(self)
object_changes = ObjectChange.objects.filter(
@ -35,7 +36,7 @@ class ChangelogMixin:
@strawberry.type
class ConfigContextMixin:
@strawberry.django.field
@strawberry_django.field
def config_context(self) -> strawberry.scalars.JSON:
return self.get_config_context()
@ -43,7 +44,7 @@ class ConfigContextMixin:
@strawberry.type
class CustomFieldsMixin:
@strawberry.django.field
@strawberry_django.field
def custom_fields(self) -> strawberry.scalars.JSON:
return self.custom_field_data
@ -51,7 +52,7 @@ class CustomFieldsMixin:
@strawberry.type
class ImageAttachmentsMixin:
@strawberry.django.field
@strawberry_django.field
def image_attachments(self) -> List[Annotated["ImageAttachmentType", strawberry.lazy('.types')]]:
return self.images.restrict(info.context.user, 'view')
@ -59,7 +60,7 @@ class ImageAttachmentsMixin:
@strawberry.type
class JournalEntriesMixin:
@strawberry.django.field
@strawberry_django.field
def journal_entries(self) -> List[Annotated["JournalEntryType", strawberry.lazy('.types')]]:
return self.journal_entries.restrict(info.context.user, 'view')
@ -67,7 +68,7 @@ class JournalEntriesMixin:
@strawberry.type
class TagsMixin:
@strawberry.django.field
@strawberry_django.field
def tags(self) -> List[Annotated["TagType", strawberry.lazy('.types')]]:
return self.tags.all()
@ -75,6 +76,6 @@ class TagsMixin:
@strawberry.type
class ContactsMixin:
@strawberry.django.field
@strawberry_django.field
def contacts(self) -> List[Annotated["ContactAssignmentType", strawberry.lazy('tenancy.graphql.types')]]:
return list(self.contacts.all())

View File

@ -1,5 +1,6 @@
import strawberry
from strawberry import auto
import strawberry_django
from extras import filtersets, models
from extras.graphql.mixins import CustomFieldsMixin, TagsMixin
@ -23,7 +24,7 @@ __all__ = (
)
@strawberry.django.type(
@strawberry_django.type(
models.ConfigContext,
fields='__all__',
filters=ConfigContextFilter
@ -32,7 +33,7 @@ class ConfigContextType(ObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.ConfigTemplate,
fields='__all__',
filters=ConfigTemplateFilter
@ -41,7 +42,7 @@ class ConfigTemplateType(TagsMixin, ObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.CustomField,
fields='__all__',
filters=CustomFieldFilter
@ -50,7 +51,7 @@ class CustomFieldType(ObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.CustomFieldChoiceSet,
fields='__all__',
filters=CustomFieldChoiceSetFilter
@ -59,7 +60,7 @@ class CustomFieldChoiceSetType(ObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.CustomLink,
fields='__all__',
filters=CustomLinkFilter
@ -68,7 +69,7 @@ class CustomLinkType(ObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.ExportTemplate,
fields='__all__',
filters=ExportTemplateFilter
@ -77,7 +78,7 @@ class ExportTemplateType(ObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.ImageAttachment,
fields='__all__',
filters=ImageAttachmentFilter
@ -86,7 +87,7 @@ class ImageAttachmentType(BaseObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.JournalEntry,
fields='__all__',
filters=JournalEntryFilter
@ -95,7 +96,7 @@ class JournalEntryType(CustomFieldsMixin, TagsMixin, ObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.ObjectChange,
fields='__all__',
filters=ObjectChangeFilter
@ -104,7 +105,7 @@ class ObjectChangeType(BaseObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.SavedFilter,
exclude=['content_types',],
filters=SavedFilterFilter
@ -113,7 +114,7 @@ class SavedFilterType(ObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.Tag,
exclude=['extras_taggeditem_items', 'color'], # bug - remove color from exclude
filters=TagFilter
@ -122,7 +123,7 @@ class TagType(ObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.Webhook,
exclude=['content_types',],
filters=WebhookFilter
@ -131,7 +132,7 @@ class WebhookType(OrganizationalObjectType):
pass
@strawberry.django.type(
@strawberry_django.type(
models.EventRule,
exclude=['content_types',],
filters=EventRuleFilter

View File

@ -1,5 +1,6 @@
import strawberry
from strawberry import auto
import strawberry_django
from django.contrib.contenttypes.models import ContentType
from extras.graphql.mixins import (
@ -32,11 +33,11 @@ class BaseObjectType:
# Enforce object permissions on the queryset
return queryset.restrict(info.context.request.user, 'view')
@strawberry.django.field
@strawberry_django.field
def display(self) -> str:
return str(self)
@strawberry.django.field
@strawberry_django.field
def class_type(self) -> str:
return self.__class__.__name__
@ -80,7 +81,7 @@ class NetBoxObjectType(
# Miscellaneous types
#
@strawberry.django.type(
@strawberry_django.type(
ContentType,
fields=['id', 'app_label', 'model'],
)

View File

@ -1,4 +1,5 @@
import strawberry
import strawberry_django
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from strawberry import auto
@ -12,7 +13,7 @@ __all__ = (
)
@strawberry.django.type(
@strawberry_django.type(
Group,
fields=['id', 'name'],
filters=GroupFilter
@ -23,7 +24,7 @@ class GroupType:
return RestrictedQuerySet(model=Group).restrict(info.context.request.user, 'view')
@strawberry.django.type(
@strawberry_django.type(
get_user_model(),
fields=[
'id', 'username', 'password', 'first_name', 'last_name', 'email', 'is_staff',