Skip to content

Commit

Permalink
blacked
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Jan 26, 2024
1 parent a12f0fe commit 81dab47
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 48 deletions.
44 changes: 26 additions & 18 deletions api/tacticalrmm/agents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,24 +507,32 @@ def get_agent_policies(self) -> "Dict[str, Optional[Policy]]":
)

return {
"agent_policy": self.policy
if self.policy and not self.policy.is_agent_excluded(self)
else None,
"site_policy": site_policy
if (site_policy and not site_policy.is_agent_excluded(self))
and not self.block_policy_inheritance
else None,
"client_policy": client_policy
if (client_policy and not client_policy.is_agent_excluded(self))
and not self.block_policy_inheritance
and not self.site.block_policy_inheritance
else None,
"default_policy": default_policy
if (default_policy and not default_policy.is_agent_excluded(self))
and not self.block_policy_inheritance
and not self.site.block_policy_inheritance
and not self.client.block_policy_inheritance
else None,
"agent_policy": (
self.policy
if self.policy and not self.policy.is_agent_excluded(self)
else None
),
"site_policy": (
site_policy
if (site_policy and not site_policy.is_agent_excluded(self))
and not self.block_policy_inheritance
else None
),
"client_policy": (
client_policy
if (client_policy and not client_policy.is_agent_excluded(self))
and not self.block_policy_inheritance
and not self.site.block_policy_inheritance
else None
),
"default_policy": (
default_policy
if (default_policy and not default_policy.is_agent_excluded(self))
and not self.block_policy_inheritance
and not self.site.block_policy_inheritance
and not self.client.block_policy_inheritance
else None
),
}

def check_run_interval(self) -> int:
Expand Down
20 changes: 11 additions & 9 deletions api/tacticalrmm/alerts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,17 @@ def create_or_return_check_alert(
assigned_check=check,
agent=agent,
alert_type=AlertType.CHECK,
severity=check.alert_severity
if check.check_type
not in {
CheckType.MEMORY,
CheckType.CPU_LOAD,
CheckType.DISK_SPACE,
CheckType.SCRIPT,
}
else alert_severity,
severity=(
check.alert_severity
if check.check_type
not in {
CheckType.MEMORY,
CheckType.CPU_LOAD,
CheckType.DISK_SPACE,
CheckType.SCRIPT,
}
else alert_severity
),
message=f"{agent.hostname} has a {check.check_type} check: {check.readable_desc} that failed.",
hidden=True,
),
Expand Down
22 changes: 13 additions & 9 deletions api/tacticalrmm/autotasks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,20 @@ def generate_nats_task_payload(self) -> Dict[str, Any]:
"name": self.win_task_name,
"overwrite_task": True,
"enabled": self.enabled,
"trigger": self.task_type
if self.task_type != TaskType.CHECK_FAILURE
else TaskType.MANUAL,
"trigger": (
self.task_type
if self.task_type != TaskType.CHECK_FAILURE
else TaskType.MANUAL
),
"multiple_instances": self.task_instance_policy or 0,
"delete_expired_task_after": self.remove_if_not_scheduled
if self.expire_date
else False,
"start_when_available": self.run_asap_after_missed
if self.task_type != TaskType.RUN_ONCE
else True,
"delete_expired_task_after": (
self.remove_if_not_scheduled if self.expire_date else False
),
"start_when_available": (
self.run_asap_after_missed
if self.task_type != TaskType.RUN_ONCE
else True
),
}

if self.task_type in (
Expand Down
6 changes: 3 additions & 3 deletions api/tacticalrmm/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def dashboard_info(request):
"show_community_scripts": request.user.show_community_scripts,
"dbl_click_action": request.user.agent_dblclick_action,
"default_agent_tbl_tab": request.user.default_agent_tbl_tab,
"url_action": request.user.url_action.id
if request.user.url_action
else None,
"url_action": (
request.user.url_action.id if request.user.url_action else None
),
"client_tree_sort": request.user.client_tree_sort,
"client_tree_splitter": request.user.client_tree_splitter,
"loading_bar_color": request.user.loading_bar_color,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This file is subject to the EE License Agreement.
For details, see: https://license.tacticalrmm.com/ee
"""

import json
from typing import TYPE_CHECKING, Any, Dict, List, Tuple

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This file is subject to the EE License Agreement.
For details, see: https://license.tacticalrmm.com/ee
"""

import urllib.parse
from time import sleep
from typing import Any, Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@ def test_generate_report_with_dependencies(
template=report_template.template_md,
template_type=report_template.type,
css=report_template.template_css if report_template.template_css else "",
html_template=report_template.template_html.id
if report_template.template_html
else None,
html_template=(
report_template.template_html.id
if report_template.template_html
else None
),
variables=report_template.template_variables,
dependencies={"client": 1},
)
Expand Down
6 changes: 3 additions & 3 deletions api/tacticalrmm/ee/reporting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ def post(self, request: Request, pk: int) -> Union[FileResponse, Response]:
template=template.template_md,
template_type=template.type,
css=template.template_css or "",
html_template=template.template_html.id
if template.template_html
else None,
html_template=(
template.template_html.id if template.template_html else None
),
variables=template.template_variables,
dependencies=request.data["dependencies"],
)
Expand Down
8 changes: 5 additions & 3 deletions api/tacticalrmm/logs/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ def test_get_audit_logs(self):
self.assertEqual(resp.status_code, 200)
self.assertEqual(
len(resp.data["audit_logs"]), # type:ignore
pagination["rowsPerPage"]
if req["count"] > pagination["rowsPerPage"]
else req["count"],
(
pagination["rowsPerPage"]
if req["count"] > pagination["rowsPerPage"]
else req["count"]
),
)
self.assertEqual(resp.data["total"], req["count"]) # type:ignore

Expand Down

0 comments on commit 81dab47

Please sign in to comment.