mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
32 lines
932 B
Python
32 lines
932 B
Python
from rest_framework import serializers
|
|
from taggit_serializer.serializers import TaggitSerializer, TagListSerializerField
|
|
|
|
from extras.api.customfields import CustomFieldModelSerializer
|
|
from tenancy.models import Tenant, TenantGroup
|
|
from utilities.api import ValidatedModelSerializer
|
|
from .nested_serializers import *
|
|
|
|
|
|
#
|
|
# Tenants
|
|
#
|
|
|
|
class TenantGroupSerializer(ValidatedModelSerializer):
|
|
tenant_count = serializers.IntegerField(read_only=True)
|
|
|
|
class Meta:
|
|
model = TenantGroup
|
|
fields = ['id', 'name', 'slug', 'tenant_count']
|
|
|
|
|
|
class TenantSerializer(TaggitSerializer, CustomFieldModelSerializer):
|
|
group = NestedTenantGroupSerializer(required=False)
|
|
tags = TagListSerializerField(required=False)
|
|
|
|
class Meta:
|
|
model = Tenant
|
|
fields = [
|
|
'id', 'name', 'slug', 'group', 'description', 'comments', 'tags', 'custom_fields', 'created',
|
|
'last_updated',
|
|
]
|