mirror of https://github.com/jumpserver/jumpserver
fix: 修复获取 swagger api 时,AssetSerializer category, type 字段手动设置 _choices 属性时报错的问题
parent
0aa681620f
commit
5fcd83b587
|
@ -52,10 +52,10 @@ class LoginACLSerializer(BulkModelSerializer):
|
|||
action = self.fields.get("action")
|
||||
if not action:
|
||||
return
|
||||
choices = action._choices
|
||||
choices = action.choices
|
||||
if not has_valid_xpack_license():
|
||||
choices.pop(LoginACL.ActionChoices.review, None)
|
||||
action._choices = choices
|
||||
action.choices = choices
|
||||
|
||||
def get_rules_serializer(self):
|
||||
return RuleSerializer()
|
||||
|
|
|
@ -139,9 +139,9 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali
|
|||
return
|
||||
category = request.path.strip('/').split('/')[-1].rstrip('s')
|
||||
field_category = self.fields.get('category')
|
||||
field_category._choices = Category.filter_choices(category)
|
||||
field_category.choices = Category.filter_choices(category)
|
||||
field_type = self.fields.get('type')
|
||||
field_type._choices = AllTypes.filter_choices(category)
|
||||
field_type.choices = AllTypes.filter_choices(category)
|
||||
|
||||
@classmethod
|
||||
def setup_eager_loading(cls, queryset):
|
||||
|
|
|
@ -70,9 +70,7 @@ class AssetPermissionSerializer(BulkOrgResourceModelSerializer):
|
|||
actions = self.fields.get("actions")
|
||||
if not actions:
|
||||
return
|
||||
choices = actions._choices
|
||||
actions._choices = choices
|
||||
actions.default = list(choices.keys())
|
||||
actions.default = list(actions.choices.keys())
|
||||
|
||||
@classmethod
|
||||
def setup_eager_loading(cls, queryset):
|
||||
|
|
|
@ -39,9 +39,9 @@ class TicketSerializer(OrgResourceModelSerializerMixin):
|
|||
tp = self.fields.get('type')
|
||||
if not tp:
|
||||
return
|
||||
choices = tp._choices
|
||||
choices = tp.choices
|
||||
choices.pop(TicketType.general, None)
|
||||
tp._choices = choices
|
||||
tp.choices = choices
|
||||
|
||||
@classmethod
|
||||
def setup_eager_loading(cls, queryset):
|
||||
|
|
Loading…
Reference in New Issue