mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-01-29 21:51:31 +00:00
perf: 修改 display field
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
from collections import Iterable
|
||||
|
||||
from django.db.models import NOT_PROVIDED
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from rest_framework.utils import html
|
||||
from django.db.models import NOT_PROVIDED
|
||||
from rest_framework import serializers
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from rest_framework.fields import SkipField, empty
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.utils import html
|
||||
|
||||
from common.drf.fields import EncryptedField
|
||||
from common.utils import lazyproperty
|
||||
|
||||
from ..fields import LabeledChoiceField, ObjectRelatedField
|
||||
|
||||
__all__ = [
|
||||
'BulkSerializerMixin', 'BulkListSerializerMixin',
|
||||
@@ -43,6 +42,7 @@ class BulkSerializerMixin(object):
|
||||
Become rest_framework_bulk not support uuid as a primary key
|
||||
so rewrite it. https://github.com/miki725/django-rest-framework-bulk/issues/66
|
||||
"""
|
||||
|
||||
def to_internal_value(self, data):
|
||||
from rest_framework_bulk import BulkListSerializer
|
||||
ret = super(BulkSerializerMixin, self).to_internal_value(data)
|
||||
@@ -308,7 +308,12 @@ class DynamicFieldsMixin:
|
||||
self.fields.pop(field, None)
|
||||
|
||||
|
||||
class CommonSerializerMixin(DynamicFieldsMixin, DefaultValueFieldsMixin):
|
||||
class RelatedModelSerializerMixin:
|
||||
serializer_related_field = ObjectRelatedField
|
||||
serializer_choice_field = LabeledChoiceField
|
||||
|
||||
|
||||
class SomeFieldsMixin:
|
||||
instance: None
|
||||
initial_data: dict
|
||||
common_fields = (
|
||||
@@ -342,5 +347,10 @@ class CommonSerializerMixin(DynamicFieldsMixin, DefaultValueFieldsMixin):
|
||||
return primary_names + common_names
|
||||
|
||||
|
||||
class CommonSerializerMixin(DynamicFieldsMixin, RelatedModelSerializerMixin,
|
||||
SomeFieldsMixin, DefaultValueFieldsMixin):
|
||||
pass
|
||||
|
||||
|
||||
class CommonBulkSerializerMixin(BulkSerializerMixin, CommonSerializerMixin):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user