mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
39 lines
714 B
Python
39 lines
714 B
Python
|
from rest_framework import serializers
|
||
|
|
||
|
from tenancy.models import Tenant, TenantGroup
|
||
|
|
||
|
|
||
|
#
|
||
|
# Tenant groups
|
||
|
#
|
||
|
|
||
|
class TenantGroupSerializer(serializers.ModelSerializer):
|
||
|
|
||
|
class Meta:
|
||
|
model = TenantGroup
|
||
|
fields = ['id', 'name', 'slug']
|
||
|
|
||
|
|
||
|
class TenantGroupNestedSerializer(TenantGroupSerializer):
|
||
|
|
||
|
class Meta(TenantGroupSerializer.Meta):
|
||
|
pass
|
||
|
|
||
|
|
||
|
#
|
||
|
# Tenants
|
||
|
#
|
||
|
|
||
|
class TenantSerializer(serializers.ModelSerializer):
|
||
|
group = TenantGroupNestedSerializer()
|
||
|
|
||
|
class Meta:
|
||
|
model = Tenant
|
||
|
fields = ['id', 'name', 'slug', 'group', 'comments']
|
||
|
|
||
|
|
||
|
class TenantNestedSerializer(TenantSerializer):
|
||
|
|
||
|
class Meta(TenantSerializer.Meta):
|
||
|
fields = ['id', 'name', 'slug']
|