1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Added child counts to API serializers (WIP)

This commit is contained in:
Jeremy Stretch
2019-04-12 17:07:56 -04:00
parent b1c160f9d4
commit a46b43bff6
26 changed files with 206 additions and 94 deletions

View File

@ -1,6 +1,7 @@
import base64
from Crypto.PublicKey import RSA
from django.db.models import Count
from django.http import HttpResponseBadRequest
from rest_framework.exceptions import ValidationError
from rest_framework.permissions import IsAuthenticated
@ -32,7 +33,9 @@ class SecretsFieldChoicesViewSet(FieldChoicesViewSet):
#
class SecretRoleViewSet(ModelViewSet):
queryset = SecretRole.objects.all()
queryset = SecretRole.objects.annotate(
secret_count=Count('secrets')
)
serializer_class = serializers.SecretRoleSerializer
permission_classes = [IsAuthenticated]
filterset_class = filters.SecretRoleFilter