From 33ce61f171f26f964ad09cddafa7ecbc9f403333 Mon Sep 17 00:00:00 2001 From: benero Date: Tue, 8 Oct 2024 18:19:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E5=99=A8=20schema=20=E8=B6=8A=E6=9D=83=E9=97=AE=E9=A2=98=20--s?= =?UTF-8?q?tory=3D119850966?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itsm/trigger/views.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/itsm/trigger/views.py b/itsm/trigger/views.py index d30a31ca..ffd1cf7e 100644 --- a/itsm/trigger/views.py +++ b/itsm/trigger/views.py @@ -232,11 +232,21 @@ def _single_update(action_data, instance): return serializer.data + trigger = self.get_object() + rules = TriggerRule.objects.filter(trigger_id=trigger.id) + actions_schemas = [] + for rule in rules: + if not rule.action_schemas: + continue + actions_schemas.extend(rule.action_schemas) + schemas = [] with transaction.atomic(): for _data in request.data: try: instance = ActionSchema.objects.get(id=_data.get("id", 0)) + if instance.id not in actions_schemas: + raise ValidationError(_("Schema ID 异常")) schema = _single_update(_data, instance) except ActionSchema.DoesNotExist: schema = _single_create(_data)