From dc1975c52c40821d09cbd7548d27f9e5520f97ee Mon Sep 17 00:00:00 2001 From: vapao Date: Thu, 24 Sep 2020 16:22:56 +0800 Subject: [PATCH] =?UTF-8?q?F=20=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E5=88=A0=E9=99=A4=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E6=9C=AA=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_api/apps/alarm/views.py | 2 +- spug_api/apps/host/views.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spug_api/apps/alarm/views.py b/spug_api/apps/alarm/views.py index e1737ca..0ff1309 100644 --- a/spug_api/apps/alarm/views.py +++ b/spug_api/apps/alarm/views.py @@ -40,7 +40,7 @@ class GroupView(View): Argument('id', type=int, help='请指定操作对象') ).parse(request.GET) if error is None: - detection = Detection.objects.filter(notify_grp__regex=fr'\D{form.id}\D').first() + detection = Detection.objects.filter(notify_grp__regex=fr'[^0-9]{form.id}[^0-9]').first() if detection: return json_response(error=f'监控任务【{detection.name}】正在使用该报警组,请解除关联后再尝试删除该联系组') Group.objects.filter(pk=form.id).delete() diff --git a/spug_api/apps/host/views.py b/spug_api/apps/host/views.py index e4cfbc3..70e5ca8 100644 --- a/spug_api/apps/host/views.py +++ b/spug_api/apps/host/views.py @@ -75,19 +75,19 @@ class HostView(View): Argument('id', type=int, help='请指定操作对象') ).parse(request.GET) if error is None: - deploy = Deploy.objects.filter(host_ids__regex=fr'\D{form.id}\D').annotate( + deploy = Deploy.objects.filter(host_ids__regex=fr'[^0-9]{form.id}[^0-9]').annotate( app_name=F('app__name'), env_name=F('env__name') ).first() if deploy: return json_response(error=f'应用【{deploy.app_name}】在【{deploy.env_name}】的发布配置关联了该主机,请解除关联后再尝试删除该主机') - task = Task.objects.filter(targets__regex=fr'\D{form.id}\D').first() + task = Task.objects.filter(targets__regex=fr'[^0-9]{form.id}[^0-9]').first() if task: return json_response(error=f'任务计划中的任务【{task.name}】关联了该主机,请解除关联后再尝试删除该主机') detection = Detection.objects.filter(type__in=('3', '4'), addr=form.id).first() if detection: return json_response(error=f'监控中心的任务【{detection.name}】关联了该主机,请解除关联后再尝试删除该主机') - role = Role.objects.filter(host_perms__regex=fr'\D{form.id}\D').first() + role = Role.objects.filter(host_perms__regex=fr'[^0-9]{form.id}[^0-9]').first() if role: return json_response(error=f'角色【{role.name}】的主机权限关联了该主机,请解除关联后再尝试删除该主机') Host.objects.filter(pk=form.id).update(