[Bugfix] 修复ops列表任务无法删除的bug

pull/3782/head
ibuler 2020-03-16 14:18:29 +08:00
parent 3afb8647bd
commit 3138abb00c
2 changed files with 2 additions and 2 deletions

View File

@ -206,7 +206,7 @@ class AdHoc(OrgModelMixin):
def __str__(self):
return "{} of {}".format(self.task.name, self.short_id)
def __eq__(self, other):
def same_with(self, other):
if not isinstance(other, self.__class__):
return False
fields_check = []

View File

@ -56,7 +56,7 @@ def update_or_create_ansible_task(
new_hosts = set([str(asset.id) for asset in hosts])
hosts_same = old_hosts == new_hosts
if not adhoc or adhoc != new_adhoc or not hosts_same:
if not adhoc or not adhoc.same_with(new_adhoc) or not hosts_same:
logger.debug(_("Update task content: {}").format(task_name))
new_adhoc.save()
new_adhoc.hosts.set(hosts)