jumpserver/apps/perms/serializers.py

27 lines
642 B
Python
Raw Normal View History

2016-10-19 11:30:55 +00:00
# -*- coding: utf-8 -*-
#
2016-11-10 08:59:50 +00:00
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from common.utils import get_object_or_none
2016-11-04 10:33:16 +00:00
from .models import AssetPermission
2016-11-10 08:59:50 +00:00
from .hands import User
2016-11-04 10:33:16 +00:00
class AssetPermissionSerializer(serializers.ModelSerializer):
class Meta:
model = AssetPermission
2017-01-20 05:59:53 +00:00
fields = '__all__'
2016-11-10 08:59:50 +00:00
class UserAssetPermissionSerializer(AssetPermissionSerializer):
is_inherited = serializers.SerializerMethodField()
@staticmethod
def get_is_inherited(obj):
if getattr(obj, 'inherited', ''):
return True
else:
return False