From bf308e24b669131b8887c071d167fe1438f921e4 Mon Sep 17 00:00:00 2001 From: xinwen Date: Wed, 16 Dec 2020 17:31:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A8=E9=80=81=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=97=B6=20AdHocExecution=20id=20=E9=87=8D?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/models/adhoc.py | 4 +++- apps/ops/utils.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/ops/models/adhoc.py b/apps/ops/models/adhoc.py index 95a1106b1..aa2884105 100644 --- a/apps/ops/models/adhoc.py +++ b/apps/ops/models/adhoc.py @@ -180,8 +180,10 @@ class AdHoc(OrgModelMixin): def run(self): try: hid = current_task.request.id + if AdHocExecution.objects.filter(id=hid).exists(): + hid = uuid.uuid4() except AttributeError: - hid = str(uuid.uuid4()) + hid = uuid.uuid4() execution = AdHocExecution( id=hid, adhoc=self, task=self.task, task_display=str(self.task)[:128], diff --git a/apps/ops/utils.py b/apps/ops/utils.py index e4fa85812..04d35a2fa 100644 --- a/apps/ops/utils.py +++ b/apps/ops/utils.py @@ -3,7 +3,7 @@ from django.utils.translation import ugettext_lazy as _ from common.utils import get_logger, get_object_or_none from common.tasks import send_mail_async -from orgs.utils import tmp_to_org, org_aware_func +from orgs.utils import org_aware_func from .models import Task, AdHoc