You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jumpserver/apps/perms/serializers.py

27 lines
642 B

8 years ago
# -*- coding: utf-8 -*-
#
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from common.utils import get_object_or_none
8 years ago
from .models import AssetPermission
from .hands import User
8 years ago
class AssetPermissionSerializer(serializers.ModelSerializer):
class Meta:
model = AssetPermission
fields = '__all__'
class UserAssetPermissionSerializer(AssetPermissionSerializer):
is_inherited = serializers.SerializerMethodField()
@staticmethod
def get_is_inherited(obj):
if getattr(obj, 'inherited', ''):
return True
else:
return False