mirror of https://github.com/jumpserver/jumpserver
parent
6c19fd4192
commit
44967b1af1
|
@ -157,20 +157,6 @@ class PlatformSerializer(WritableNestedModelSerializer):
|
||||||
constraints = AllTypes.get_constraints(category, tp)
|
constraints = AllTypes.get_constraints(category, tp)
|
||||||
return constraints
|
return constraints
|
||||||
|
|
||||||
def validate(self, attrs):
|
|
||||||
domain_enabled = attrs.get('domain_enabled', False) and self.constraints.get('domain_enabled', False)
|
|
||||||
su_enabled = attrs.get('su_enabled', False) and self.constraints.get('su_enabled', False)
|
|
||||||
automation = attrs.get('automation', {})
|
|
||||||
automation['ansible_enabled'] = automation.get('ansible_enabled', False) \
|
|
||||||
and self.constraints['automation'].get('ansible_enabled', False)
|
|
||||||
attrs.update({
|
|
||||||
'domain_enabled': domain_enabled,
|
|
||||||
'su_enabled': su_enabled,
|
|
||||||
'automation': automation,
|
|
||||||
})
|
|
||||||
self.initial_data['automation'] = automation
|
|
||||||
return attrs
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_eager_loading(cls, queryset):
|
def setup_eager_loading(cls, queryset):
|
||||||
queryset = queryset.prefetch_related(
|
queryset = queryset.prefetch_related(
|
||||||
|
@ -188,6 +174,18 @@ class PlatformSerializer(WritableNestedModelSerializer):
|
||||||
self.initial_data['protocols'] = protocols
|
self.initial_data['protocols'] = protocols
|
||||||
return protocols
|
return protocols
|
||||||
|
|
||||||
|
def validate_su_enabled(self, su_enabled):
|
||||||
|
return su_enabled and self.constraints.get('su_enabled', False)
|
||||||
|
|
||||||
|
def validate_domain_enabled(self, domain_enabled):
|
||||||
|
return domain_enabled and self.constraints.get('domain_enabled', False)
|
||||||
|
|
||||||
|
def validate_automation(self, automation):
|
||||||
|
automation = automation or {}
|
||||||
|
automation = automation.get('ansible_enabled', False) \
|
||||||
|
and self.constraints['automation'].get('ansible_enabled', False)
|
||||||
|
return automation
|
||||||
|
|
||||||
|
|
||||||
class PlatformOpsMethodSerializer(serializers.Serializer):
|
class PlatformOpsMethodSerializer(serializers.Serializer):
|
||||||
id = serializers.CharField(read_only=True)
|
id = serializers.CharField(read_only=True)
|
||||||
|
|
Loading…
Reference in New Issue