A api fix bug

pull/22/head
雷二猛 2019-12-02 20:50:30 +08:00
parent b28c24e734
commit 86ede36795
1 changed files with 6 additions and 4 deletions

View File

@ -32,10 +32,12 @@ class Schedule(View):
updated_by=request.user, updated_by=request.user,
**form **form
) )
form.action = 'modify' task = Task.objects.filter(pk=form.id).first()
form.targets = json.loads(form.targets) if task and task.is_active:
rds_cli = get_redis_connection() form.action = 'modify'
rds_cli.rpush(settings.SCHEDULE_KEY, json.dumps(form)) form.targets = json.loads(form.targets)
rds_cli = get_redis_connection()
rds_cli.rpush(settings.SCHEDULE_KEY, json.dumps(form))
else: else:
Task.objects.create(created_by=request.user, **form) Task.objects.create(created_by=request.user, **form)
return json_response(error=error) return json_response(error=error)