Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes running in netbox-docker with errors on version strings #59

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions netbox_diode_plugin/api/serializers.py
Original file line number Diff line number Diff line change
@@ -19,10 +19,16 @@

from netbox_diode_plugin.models import Setting

if version.parse(version.parse(settings.VERSION).base_version) >= version.parse("4.1"):
try:
if version.parse(version.parse(settings.VERSION).base_version) >= version.parse(
"4.1"
):
from core.models import ObjectChange
else:
from extras.models import ObjectChange
except version.InvalidVersion:
from core.models import ObjectChange
else:
from extras.models import ObjectChange

from ipam.api.serializers import IPAddressSerializer, PrefixSerializer
from rest_framework import serializers
from utilities.api import get_serializer_for_model
9 changes: 6 additions & 3 deletions netbox_diode_plugin/api/views.py
Original file line number Diff line number Diff line change
@@ -7,10 +7,13 @@
from django.conf import settings
from packaging import version

if version.parse(settings.VERSION).major >= 4:
try:
if version.parse(settings.VERSION).major >= 4:
from core.models import ObjectType as NetBoxType
else:
from django.contrib.contenttypes.models import ContentType as NetBoxType
except version.InvalidVersion:
from core.models import ObjectType as NetBoxType
else:
from django.contrib.contenttypes.models import ContentType as NetBoxType
from django.core.exceptions import FieldError
from django.db import transaction
from django.db.models import Q
9 changes: 6 additions & 3 deletions netbox_diode_plugin/tables.py
Original file line number Diff line number Diff line change
@@ -8,10 +8,13 @@
from django.conf import settings
from packaging import version

if version.parse(settings.VERSION).major >= 4:
try:
if version.parse(settings.VERSION).major >= 4:
from core.models import ObjectType as NetBoxType
else:
from django.contrib.contenttypes.models import ContentType as NetBoxType
except version.InvalidVersion:
from core.models import ObjectType as NetBoxType
else:
from django.contrib.contenttypes.models import ContentType as NetBoxType

from netbox.tables import BaseTable, columns
from utilities.object_types import object_type_identifier, object_type_name