fix: Serializer für Dokumentanhänge ergänzen
This commit is contained in:
@@ -20,7 +20,7 @@ Ein in NetBox integriertes Markdown-Wiki für Betriebsdokumentationen und Anleit
|
||||
|
||||
## Kompatibilität
|
||||
|
||||
Die Version `0.3.3` zielt auf NetBox 4.x (mindestens 4.0). Vor einem produktiven Rollout sollte das Plugin gegen die konkret eingesetzte NetBox-Minor-Version in einer Testinstanz geprüft werden.
|
||||
Die Version `0.3.4` zielt auf NetBox 4.x (mindestens 4.0). Vor einem produktiven Rollout sollte das Plugin gegen die konkret eingesetzte NetBox-Minor-Version in einer Testinstanz geprüft werden.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -125,6 +125,7 @@ Nach Aktivierung stehen die üblichen NetBox-Plugin-Endpunkte bereit:
|
||||
- `/api/plugins/documentation/documents/`
|
||||
- `/api/plugins/documentation/assignments/`
|
||||
- `/api/plugins/documentation/folders/`
|
||||
- `/api/plugins/documentation/attachments/`
|
||||
|
||||
## Entwicklung und Tests
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class DocumentationConfig(PluginConfig):
|
||||
name = "netbox_documentation"
|
||||
verbose_name = "Dokumentation"
|
||||
description = "Wiki und Office-Dokumentation direkt in NetBox"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
author = "NetBox Documentation Contributors"
|
||||
base_url = "documentation"
|
||||
min_version = "4.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from netbox.api.serializers import NetBoxModelSerializer
|
||||
from rest_framework import serializers
|
||||
from ..models import Document, DocumentAssignment, DocumentCategory
|
||||
from ..models import Document, DocumentAssignment, DocumentAttachment, DocumentCategory
|
||||
|
||||
|
||||
class DocumentSerializer(NetBoxModelSerializer):
|
||||
@@ -25,3 +25,14 @@ class DocumentCategorySerializer(NetBoxModelSerializer):
|
||||
class Meta:
|
||||
model = DocumentCategory
|
||||
fields = ("id", "url", "display", "name", "slug", "parent", "description", "tags", "created", "last_updated")
|
||||
|
||||
|
||||
class DocumentAttachmentSerializer(NetBoxModelSerializer):
|
||||
url = serializers.HyperlinkedIdentityField(view_name="plugins-api:netbox_documentation-api:documentattachment-detail")
|
||||
|
||||
class Meta:
|
||||
model = DocumentAttachment
|
||||
fields = (
|
||||
"id", "url", "display", "document", "file", "original_name",
|
||||
"content_type", "size", "tags", "created", "last_updated",
|
||||
)
|
||||
|
||||
@@ -5,4 +5,5 @@ router = NetBoxRouter()
|
||||
router.register("documents", views.DocumentViewSet)
|
||||
router.register("assignments", views.DocumentAssignmentViewSet)
|
||||
router.register("folders", views.DocumentCategoryViewSet)
|
||||
router.register("attachments", views.DocumentAttachmentViewSet)
|
||||
urlpatterns = router.urls
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
from netbox.api.viewsets import NetBoxModelViewSet
|
||||
from ..filtersets import DocumentFilterSet, AssignmentFilterSet, DocumentCategoryFilterSet
|
||||
from ..models import Document, DocumentAssignment, DocumentCategory
|
||||
from .serializers import DocumentSerializer, DocumentAssignmentSerializer, DocumentCategorySerializer
|
||||
from ..models import Document, DocumentAssignment, DocumentAttachment, DocumentCategory
|
||||
from .serializers import (
|
||||
DocumentSerializer, DocumentAssignmentSerializer, DocumentAttachmentSerializer,
|
||||
DocumentCategorySerializer,
|
||||
)
|
||||
|
||||
|
||||
class DocumentViewSet(NetBoxModelViewSet):
|
||||
@@ -20,3 +23,9 @@ class DocumentCategoryViewSet(NetBoxModelViewSet):
|
||||
queryset = DocumentCategory.objects.all()
|
||||
serializer_class = DocumentCategorySerializer
|
||||
filterset_class = DocumentCategoryFilterSet
|
||||
|
||||
|
||||
class DocumentAttachmentViewSet(NetBoxModelViewSet):
|
||||
queryset = DocumentAttachment.objects.all()
|
||||
serializer_class = DocumentAttachmentSerializer
|
||||
filterset_fields = ("id", "document_id", "content_type")
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "netbox-documentation"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
description = "Integrated Markdown wiki and office document importer for NetBox"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
|
||||
Reference in New Issue
Block a user