Skip to content

Commit

Permalink
Merge pull request #60 from Kani999/59-netbox-v4_0-compatibility
Browse files Browse the repository at this point in the history
Support NetBox v4
  • Loading branch information
Kani999 authored May 21, 2024
2 parents 079f5ea + e1a8b80 commit ab6af78
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ This plugin provide following Models:
| >= 3.4.3 | 1.0.7 <-> 1.1.X |
| >= 3.5.0 | 2.0.0 |
| >= 3.6.0 | 3.0.0 |
| >= 3.7.0 | 4.0.0
| >= 3.7.0 | 4.0.0 |
| >= 4.0.0 | 5.0.0 |

## Installation

Expand Down
7 changes: 3 additions & 4 deletions netbox_attachments/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from extras.plugins import PluginConfig

from netbox.plugins import PluginConfig
from .version import __version__


Expand All @@ -16,8 +15,8 @@ class NetBoxAttachmentsConfig(PluginConfig):
'display_setting': {}
}
required_settings = []
min_version = '3.5.0'
max_version = '3.7.99'
min_version = '4.0.0'
max_version = '4.0.99'


config = NetBoxAttachmentsConfig
5 changes: 3 additions & 2 deletions netbox_attachments/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
#from drf_yasg.utils import swagger_serializer_method
# from drf_yasg.utils import swagger_serializer_method
from netbox.api.fields import ContentTypeField
from netbox.api.serializers import NetBoxModelSerializer
from netbox.constants import NESTED_SERIALIZER_PREFIX
Expand All @@ -23,6 +23,7 @@ class Meta:
fields = [
'id', 'url', 'display', 'content_type', 'object_id', 'parent', 'name', 'description', 'file', 'created', 'last_updated', 'comments',
]
brief_fields = ('id', 'url', 'display', 'name', 'description', 'file')

def validate(self, data):
# Validate that the parent object exists
Expand All @@ -41,7 +42,7 @@ def validate(self, data):

return data

#@swagger_serializer_method(serializer_or_field=serializers.JSONField)
# @swagger_serializer_method(serializer_or_field=serializers.JSONField)
def get_parent(self, obj):
if obj.parent:
serializer = get_serializer_for_model(
Expand Down
2 changes: 1 addition & 1 deletion netbox_attachments/navigation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from extras.plugins import PluginMenu, PluginMenuItem
from netbox.plugins import PluginMenu, PluginMenuItem

menu = PluginMenu(
label='Attachments',
Expand Down
5 changes: 3 additions & 2 deletions netbox_attachments/template_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.db.utils import OperationalError
from extras.plugins import PluginTemplateExtension
from netbox.plugins import PluginTemplateExtension

from netbox.views import generic
from utilities.views import ViewTab, register_model_view
from netbox.context import current_request
Expand Down Expand Up @@ -99,7 +100,7 @@ def __init__(self, *args, **kwargs):
object_id=obj.id,
).restrict(current_request.get().user, 'view').count(),
hide_if_empty=False,
permission = "netbox_attachments.view_netboxattachment"
permission="netbox_attachments.view_netboxattachment"
)

def get_children(self, request, parent):
Expand Down
2 changes: 1 addition & 1 deletion netbox_attachments/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.0.2"
__version__ = "5.0.0"
7 changes: 6 additions & 1 deletion netbox_attachments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ class NetBoxAttachmentView(generic.ObjectView):


class NetBoxAttachmentListView(generic.ObjectListView):
actions = ['export']
actions = {
'import': {'add'},
'export': set(),
'bulk_edit': {'change'},
'bulk_delete': {'delete'},
}
queryset = models.NetBoxAttachment.objects.all()
table = tables.NetBoxAttachmentTable
filterset = filtersets.NetBoxAttachmentFilterSet
Expand Down

0 comments on commit ab6af78

Please sign in to comment.