diff --git a/nautobot_device_lifecycle_mgmt/__init__.py b/nautobot_device_lifecycle_mgmt/__init__.py index a4bbcdf3..dbaead21 100644 --- a/nautobot_device_lifecycle_mgmt/__init__.py +++ b/nautobot_device_lifecycle_mgmt/__init__.py @@ -7,11 +7,18 @@ __version__ = metadata.version(__name__) +from packaging import version + +from django.conf import settings from django.db.models.signals import post_migrate from nautobot.extras.plugins import PluginConfig +current_nautobot_version = version.parse(settings.VERSION) +NAUTOBOT_GRAPHQL_FIX = version.parse("1.2.0b1") + + class DeviceLifeCycleConfig(PluginConfig): """Plugin configuration for the Device Lifecycle Management plugin.""" @@ -30,14 +37,18 @@ class DeviceLifeCycleConfig(PluginConfig): def ready(self): """Register custom signals.""" - super().ready() import nautobot_device_lifecycle_mgmt.signals # pylint: disable=C0415,W0611 # noqa: F401 - from .signals import ( # pylint: disable=import-outside-toplevel post_migrate_create_relationships, ) + # Workaround for https://github.com/nautobot/nautobot/issues/567 for Nautobot < 1.2.0b1 + if current_nautobot_version < NAUTOBOT_GRAPHQL_FIX: + import nautobot.extras.graphql.types # pylint: disable=import-outside-toplevel, unused-import # noqa: F401 + post_migrate.connect(post_migrate_create_relationships, sender=self) + super().ready() + config = DeviceLifeCycleConfig # pylint:disable=invalid-name diff --git a/nautobot_device_lifecycle_mgmt/graphql/types.py b/nautobot_device_lifecycle_mgmt/graphql/types.py index 3776f416..d64a46fe 100644 --- a/nautobot_device_lifecycle_mgmt/graphql/types.py +++ b/nautobot_device_lifecycle_mgmt/graphql/types.py @@ -1,63 +1,16 @@ """GraphQL implementation for the Device LifeCycle Management plugin.""" import graphene -from nautobot.extras.graphql.types import DjangoObjectType +from graphene_django import DjangoObjectType + from nautobot_device_lifecycle_mgmt.models import ( - HardwareLCM, - ContractLCM, - ProviderLCM, - ContactLCM, ValidatedSoftwareLCM, ) from nautobot_device_lifecycle_mgmt.filters import ( - HardwareLCMFilterSet, - ContractLCMFilterSet, - ProviderLCMFilterSet, - ContactLCMFilterSet, ValidatedSoftwareLCMFilterSet, ) -class HardwareLCMType(DjangoObjectType): - """Graphql Type Object for the Device Lifecycle model.""" - - class Meta: - """Metadata magic method for the HardwareLCMType.""" - - model = HardwareLCM - filterset_class = HardwareLCMFilterSet - - -class ContractLCMType(DjangoObjectType): - """Graphql Type Object for the Device Lifecycle model.""" - - class Meta: - """Metadata magic method for the ContractLCMType.""" - - model = ContractLCM - filterset_class = ContractLCMFilterSet - - -class ProviderLCMType(DjangoObjectType): - """Graphql Type Object for the Device Lifecycle model.""" - - class Meta: - """Metadata magic method for the ProviderLCMType.""" - - model = ProviderLCM - filterset_class = ProviderLCMFilterSet - - -class ContactLCMType(DjangoObjectType): - """Graphql Type Object for the Device Lifecycle model.""" - - class Meta: - """Metadata magic method for the ContactLCMType.""" - - model = ContactLCM - filterset_class = ContactLCMFilterSet - - class ValidatedSoftwareLCMType(DjangoObjectType): """Graphql Type Object for the ValidatedSoftwareLCM model.""" @@ -71,9 +24,5 @@ class Meta: graphql_types = [ - HardwareLCMType, - ContractLCMType, - ProviderLCMType, - ContactLCMType, ValidatedSoftwareLCMType, ]