mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Initial multitenancy implementation
This commit is contained in:
38
netbox/tenancy/api/serializers.py
Normal file
38
netbox/tenancy/api/serializers.py
Normal file
@@ -0,0 +1,38 @@
|
||||
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']
|
Reference in New Issue
Block a user