-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for creating default configuration settings for projects…
… on project creation (#2729) * Adds support for creating default settings for projects * Improvements and bugfixes
- Loading branch information
Showing
7 changed files
with
292 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
default_case_priorities = [ | ||
{ | ||
"name": "Low", | ||
"description": "This case should be triaged on a best-effort basis.", | ||
"view_order": 1, | ||
"color": "#8bc34a", | ||
"default": True, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "Medium", | ||
"description": "This case should be triaged within 24hrs of case creation.", | ||
"view_order": 2, | ||
"color": "#ffeb3b", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "High", | ||
"description": "This case should be triaged within 8hrs of case creation.", | ||
"view_order": 3, | ||
"color": "#ff9800", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "Critical", | ||
"description": "This case should be triaged immediately.", | ||
"view_order": 4, | ||
"color": "#e53935", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "Optional", | ||
"description": "Triage of this case is optional.", | ||
"view_order": 5, | ||
"color": "#9e9e9e", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
default_case_severities = [ | ||
{ | ||
"name": "Undetermined", | ||
"description": "The severity of the case has not yet been determined.", | ||
"view_order": 1, | ||
"color": "#9e9e9e", | ||
"default": True, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "Low", | ||
"description": "Low severity.", | ||
"view_order": 2, | ||
"color": "#8bc34a", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "Medium", | ||
"description": "Medium severity.", | ||
"view_order": 3, | ||
"color": "#ffeb3b", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "High", | ||
"description": "High severity.", | ||
"view_order": 4, | ||
"color": "#ff9800", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "Critical", | ||
"description": "Critical severity.", | ||
"view_order": 5, | ||
"color": "#e53935", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
default_incident_priorities = [ | ||
{ | ||
"name": "Low", | ||
"description": "This incident may require your team's attention during working hours until the incident is stable.", | ||
"view_order": 1, | ||
"tactical_report_reminder": 12, | ||
"executive_report_reminder": 9999, | ||
"color": "#8bc34a", | ||
"page_commander": False, | ||
"default": True, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "Medium", | ||
"description": "This incident may require your team's full attention during waking hours, including weekends, until the incident is stable.", | ||
"view_order": 2, | ||
"tactical_report_reminder": 6, | ||
"executive_report_reminder": 12, | ||
"color": "#ff9800", | ||
"page_commander": False, | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "High", | ||
"description": "This incident may require your team's full attention 24x7, and should be prioritized over all other work, until the incident is stable.", | ||
"view_order": 3, | ||
"tactical_report_reminder": 2, | ||
"executive_report_reminder": 6, | ||
"color": "#e53935", | ||
"page_commander": False, | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
default_incident_severities = [ | ||
{ | ||
"name": "Undetermined", | ||
"description": "The severity of the incident has not yet been determined.", | ||
"view_order": 1, | ||
"color": "#9e9e9e", | ||
"default": True, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "Low", | ||
"description": "Low severity.", | ||
"view_order": 2, | ||
"color": "#8bc34a", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "Medium", | ||
"description": "Medium severity.", | ||
"view_order": 3, | ||
"color": "#ffeb3b", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "High", | ||
"description": "High severity.", | ||
"view_order": 4, | ||
"color": "#ff9800", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
{ | ||
"name": "Critical", | ||
"description": "Critical severity.", | ||
"view_order": 5, | ||
"color": "#e53935", | ||
"default": False, | ||
"enabled": True, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
default_incident_cost_type = { | ||
"name": "Response Cost", | ||
"description": "Cost associated with handling an incident.", | ||
"category": "Primary", | ||
"details": {}, | ||
"default": True, | ||
"editable": False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
from dispatch.decorators import background_task | ||
from dispatch.case.priority import service as case_priority_service | ||
from dispatch.case.priority.config import default_case_priorities | ||
from dispatch.case.priority.models import CasePriorityCreate | ||
from dispatch.case.severity import service as case_severity_service | ||
from dispatch.case.severity.config import default_case_severities | ||
from dispatch.case.severity.models import CaseSeverityCreate | ||
from dispatch.incident.priority import service as incident_priority_service | ||
from dispatch.incident.priority.config import default_incident_priorities | ||
from dispatch.incident.priority.models import IncidentPriorityCreate | ||
from dispatch.incident.severity import service as incident_severity_service | ||
from dispatch.incident.severity.config import default_incident_severities | ||
from dispatch.incident.severity.models import IncidentSeverityCreate | ||
from dispatch.incident_cost_type import service as incident_cost_type_service | ||
from dispatch.incident_cost_type.config import default_incident_cost_type | ||
from dispatch.incident_cost_type.models import IncidentCostTypeCreate | ||
from dispatch.plugin import service as plugin_service | ||
from dispatch.plugin.models import PluginInstanceCreate | ||
|
||
from .service import get | ||
|
||
|
||
@background_task | ||
def project_create_flow(*, organization_slug: str, project_id: int, db_session=None): | ||
project = get(db_session=db_session, project_id=project_id) | ||
|
||
# Add all plugins in disabled mode | ||
plugins = plugin_service.get_all(db_session=db_session) | ||
for plugin in plugins: | ||
plugin_instance_in = PluginInstanceCreate( | ||
project=project, plugin=plugin, configuration={}, enabled=False | ||
) | ||
plugin_service.create_instance(db_session=db_session, plugin_instance_in=plugin_instance_in) | ||
|
||
# Create default incident priorities | ||
for priority in default_incident_priorities: | ||
incident_priority_in = IncidentPriorityCreate( | ||
name=priority["name"], | ||
description=priority["description"], | ||
page_commander=priority["page_commander"], | ||
tactical_report_reminder=priority["tactical_report_reminder"], | ||
executive_report_reminder=priority["executive_report_reminder"], | ||
project=project, | ||
default=priority["default"], | ||
enabled=priority["enabled"], | ||
view_order=priority["view_order"], | ||
color=priority["color"], | ||
) | ||
incident_priority_service.create( | ||
db_session=db_session, incident_priority_in=incident_priority_in | ||
) | ||
|
||
# Create default incident severities | ||
for severity in default_incident_severities: | ||
incident_severity_in = IncidentSeverityCreate( | ||
name=severity["name"], | ||
description=severity["description"], | ||
project=project, | ||
default=severity["default"], | ||
enabled=severity["enabled"], | ||
view_order=severity["view_order"], | ||
color=severity["color"], | ||
) | ||
incident_severity_service.create( | ||
db_session=db_session, incident_severity_in=incident_severity_in | ||
) | ||
|
||
# Create default incident response cost | ||
incident_cost_type_in = IncidentCostTypeCreate( | ||
name=default_incident_cost_type["name"], | ||
description=default_incident_cost_type["description"], | ||
category=default_incident_cost_type["category"], | ||
details=default_incident_cost_type["details"], | ||
default=default_incident_cost_type["default"], | ||
editable=default_incident_cost_type["editable"], | ||
project=project, | ||
) | ||
incident_cost_type_service.create( | ||
db_session=db_session, incident_cost_type_in=incident_cost_type_in | ||
) | ||
|
||
# Create default case priorities | ||
for priority in default_case_priorities: | ||
case_priority_in = CasePriorityCreate( | ||
name=priority["name"], | ||
description=priority["description"], | ||
project=project, | ||
default=priority["default"], | ||
enabled=priority["enabled"], | ||
view_order=priority["view_order"], | ||
color=priority["color"], | ||
) | ||
case_priority_service.create(db_session=db_session, case_priority_in=case_priority_in) | ||
|
||
# Create default case severities | ||
for severity in default_case_severities: | ||
case_severity_in = CaseSeverityCreate( | ||
name=severity["name"], | ||
description=severity["description"], | ||
project=project, | ||
default=severity["default"], | ||
enabled=severity["enabled"], | ||
view_order=severity["view_order"], | ||
color=severity["color"], | ||
) | ||
case_severity_service.create(db_session=db_session, case_severity_in=case_severity_in) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters