fix: checktaskset create bug

This commit is contained in:
caoqianming 2024-06-11 16:08:21 +08:00
parent a9cbd846cd
commit 388b28133f
1 changed files with 6 additions and 1 deletions

View File

@ -83,13 +83,18 @@ class CheckTaskSetCreateSerializer(CustomModelSerializer):
with transaction.atomic():
sch = validated_data["myschedule"]
pobj = PeriodicTask()
pobj.name = 'checktask_' + time.strftime('%Y%m%d%H%M%S')
pobj.task = 'apps.dpm.dispath_checkwork_task'
if sch.crontab:
pobj.crontab = sch.crontab
elif sch.interval:
pobj.interval = sch.interval
pobj.save()
validated_data["periodictask"] = pobj
return super().create(validated_data)
ins = super().create(validated_data)
pobj.kwargs = json.dumps({'checktaskset': ins.id})
pobj.save()
return ins
class CheckTaskSetUpdateSerializer(CustomModelSerializer):
class Meta: