Merge pull request #1301 from af7567/policyselect2
break from loop once a valid policy is found. remove old unused list
This commit is contained in:
commit
61807bdaaa
|
@ -618,17 +618,14 @@ class Agent(BaseAuditModel):
|
|||
if not agent_policy:
|
||||
agent_policy = WinUpdatePolicy.objects.create(agent=self)
|
||||
|
||||
# Get the list of policies applied to the agent and select the
|
||||
# highest priority one.
|
||||
policies = self.get_agent_policies()
|
||||
|
||||
processed_policies: List[int] = []
|
||||
for _, policy in policies.items():
|
||||
if (
|
||||
policy
|
||||
and policy.active
|
||||
and policy.pk not in processed_policies
|
||||
and policy.winupdatepolicy.exists()
|
||||
):
|
||||
if policy and policy.active and policy.winupdatepolicy.exists():
|
||||
patch_policy = policy.winupdatepolicy.first()
|
||||
break
|
||||
|
||||
# if policy still doesn't exist return the agent patch policy
|
||||
if not patch_policy:
|
||||
|
|
Loading…
Reference in New Issue