mirror of https://github.com/openspug/spug
F 修复某些情况下删除条件检查未生效的问题
parent
dd6d76bd12
commit
dc1975c52c
|
@ -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()
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue