fix: 自定义平台无自动化任务

pull/10543/head^2
feng 2023-05-25 15:11:54 +08:00 committed by Jiangjie.Bai
parent cc2e42c77a
commit f20a4beef3
1 changed files with 4 additions and 0 deletions

View File

@ -94,6 +94,7 @@ class Applet(JMSBaseModel):
@classmethod
def load_platform_if_need(cls, d):
from assets.serializers import PlatformSerializer
from assets.const import CustomTypes
if not os.path.exists(os.path.join(d, 'platform.yml')):
return
@ -111,6 +112,9 @@ class Applet(JMSBaseModel):
except KeyError:
raise ValidationError({'error': _('Missing type in platform.yml')})
if not data.get('automation'):
data['automation'] = CustomTypes._get_automation_constrains()['*']
s = PlatformSerializer(data=data)
s.add_type_choices(tp, tp)
s.is_valid(raise_exception=True)