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")
|
action = self.fields.get("action")
|
||||||
if not action:
|
if not action:
|
||||||
return
|
return
|
||||||
choices = action._choices
|
choices = action.choices
|
||||||
if not has_valid_xpack_license():
|
if not has_valid_xpack_license():
|
||||||
choices.pop(LoginACL.ActionChoices.review, None)
|
choices.pop(LoginACL.ActionChoices.review, None)
|
||||||
action._choices = choices
|
action.choices = choices
|
||||||
|
|
||||||
def get_rules_serializer(self):
|
def get_rules_serializer(self):
|
||||||
return RuleSerializer()
|
return RuleSerializer()
|
||||||
|
|
|
@ -139,9 +139,9 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali
|
||||||
return
|
return
|
||||||
category = request.path.strip('/').split('/')[-1].rstrip('s')
|
category = request.path.strip('/').split('/')[-1].rstrip('s')
|
||||||
field_category = self.fields.get('category')
|
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 = self.fields.get('type')
|
||||||
field_type._choices = AllTypes.filter_choices(category)
|
field_type.choices = AllTypes.filter_choices(category)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_eager_loading(cls, queryset):
|
def setup_eager_loading(cls, queryset):
|
||||||
|
|
|
@ -70,9 +70,7 @@ class AssetPermissionSerializer(BulkOrgResourceModelSerializer):
|
||||||
actions = self.fields.get("actions")
|
actions = self.fields.get("actions")
|
||||||
if not actions:
|
if not actions:
|
||||||
return
|
return
|
||||||
choices = actions._choices
|
actions.default = list(actions.choices.keys())
|
||||||
actions._choices = choices
|
|
||||||
actions.default = list(choices.keys())
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_eager_loading(cls, queryset):
|
def setup_eager_loading(cls, queryset):
|
||||||
|
|
|
@ -39,9 +39,9 @@ class TicketSerializer(OrgResourceModelSerializerMixin):
|
||||||
tp = self.fields.get('type')
|
tp = self.fields.get('type')
|
||||||
if not tp:
|
if not tp:
|
||||||
return
|
return
|
||||||
choices = tp._choices
|
choices = tp.choices
|
||||||
choices.pop(TicketType.general, None)
|
choices.pop(TicketType.general, None)
|
||||||
tp._choices = choices
|
tp.choices = choices
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_eager_loading(cls, queryset):
|
def setup_eager_loading(cls, queryset):
|
||||||
|
|
Loading…
Reference in New Issue