mirror of https://github.com/jumpserver/jumpserver
perf(application): 优化type优先级
parent
ba4e6e9a9f
commit
f6d9af8beb
|
@ -16,7 +16,7 @@ class ApplicationSerializer(BulkOrgResourceModelSerializer):
|
||||||
model = models.Application
|
model = models.Application
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'name', 'category', 'type', 'get_type_display', 'attrs',
|
'id', 'name', 'category', 'type', 'get_type_display', 'attrs',
|
||||||
'created_by', 'date_created', 'date_updated', 'comment'
|
'domain', 'created_by', 'date_created', 'date_updated', 'comment'
|
||||||
]
|
]
|
||||||
read_only_fields = [
|
read_only_fields = [
|
||||||
'created_by', 'date_created', 'date_updated', 'get_type_display',
|
'created_by', 'date_created', 'date_updated', 'get_type_display',
|
||||||
|
@ -26,15 +26,15 @@ class ApplicationSerializer(BulkOrgResourceModelSerializer):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
app_type = ''
|
app_type = ''
|
||||||
attrs_data = {}
|
attrs_data = {}
|
||||||
if self.instance:
|
|
||||||
app_type = self.instance.type
|
|
||||||
attrs_data = self.instance.attrs
|
|
||||||
request = self.context.get('request')
|
request = self.context.get('request')
|
||||||
if request:
|
if request:
|
||||||
app_type = request.query_params.get('type')
|
app_type = request.query_params.get('type')
|
||||||
if hasattr(self, 'initial_data'):
|
if hasattr(self, 'initial_data'):
|
||||||
app_type = self.initial_data.get('type')
|
app_type = self.initial_data.get('type')
|
||||||
attrs_data = self.initial_data.get('attrs')
|
attrs_data = self.initial_data.get('attrs')
|
||||||
|
if self.instance:
|
||||||
|
app_type = self.instance.type
|
||||||
|
attrs_data = self.instance.attrs
|
||||||
if not app_type:
|
if not app_type:
|
||||||
return
|
return
|
||||||
attrs_cls = models.Category.get_type_serializer_cls(app_type)
|
attrs_cls = models.Category.get_type_serializer_cls(app_type)
|
||||||
|
|
Loading…
Reference in New Issue