jumpserver/apps/assets/serializers/account/template.py

20 lines
678 B
Python
Raw Normal View History

2022-08-24 08:36:42 +00:00
from assets.models import AccountTemplate
2022-09-23 10:59:19 +00:00
from .base import BaseAccountSerializer
2022-08-24 08:36:42 +00:00
2022-09-23 10:59:19 +00:00
class AccountTemplateSerializer(BaseAccountSerializer):
class Meta(BaseAccountSerializer.Meta):
2022-08-24 08:36:42 +00:00
model = AccountTemplate
2022-11-04 03:39:34 +00:00
# @classmethod
# def validate_required(cls, attrs):
# # TODO 选择模版后检查一些必填项
# required_field_dict = {}
# error = _('This field is required.')
# for k, v in cls().fields.items():
# if v.required and k not in attrs:
# required_field_dict[k] = error
# if not required_field_dict:
# return
# raise serializers.ValidationError(required_field_dict)