incidents ¤
Modules:
admin ¤
Classes:
-
EnvironmentAdmin
– -
IncidentAdmin
– -
IncidentRoleTypeAdmin
–IncidentRoleTypes are fixed at the moment (only commander and communication lead).
EnvironmentAdmin ¤
Bases: ModelAdmin[Environment]
Methods:
-
get_readonly_fields
–Deny changing the value of an existing object.
IncidentAdmin ¤
Bases: ModelAdmin[Incident]
Methods:
-
compute_and_purge_metrics
–Will compute metrics for selected incidents and delete metrics that can no longer be computed.
-
send_message
–Action to send a message in selected channels.
compute_and_purge_metrics ¤
Will compute metrics for selected incidents and delete metrics that can no longer be computed.
Source code in src/firefighter/incidents/admin.py
send_message ¤
send_message(request: HttpRequest, queryset: QuerySet[Incident]) -> TemplateResponse | None
Action to send a message in selected channels. This action first displays a confirmation page to enter the message. Next, it sends the message on all selected objects and redirects back to the change list (other fn).
Source code in src/firefighter/incidents/admin.py
IncidentRoleTypeAdmin ¤
Bases: ModelAdmin[IncidentRoleType]
IncidentRoleTypes are fixed at the moment (only commander and communication lead).
forms ¤
Modules:
select_impact ¤
Classes:
SelectImpactForm ¤
Bases: Form
Methods:
-
save
–Save the impact choices to the incident.
-
suggest_priority_from_impact
–Suggest a priority from 1 (highest) to 4 (lowest) based on the impact choices.
Attributes:
-
business_impact_new
(str | None
) –Get business impact. Will return N/A, Lowest, Low, Medium, High or Highest.
Source code in src/firefighter/incidents/forms/select_impact.py
business_impact_new property
¤
business_impact_new: str | None
Get business impact. Will return N/A, Lowest, Low, Medium, High or Highest.
save ¤
Save the impact choices to the incident.
Source code in src/firefighter/incidents/forms/select_impact.py
suggest_priority_from_impact ¤
suggest_priority_from_impact() -> int
Suggest a priority from 1 (highest) to 4 (lowest) based on the impact choices.
Source code in src/firefighter/incidents/forms/select_impact.py
update_key_events ¤
Classes:
IncidentUpdateKeyEventsForm ¤
Bases: Form
Methods:
-
get_milestones_with_data
–Get each firefighter.incidents.models.milestone_type.MilestoneType with its
event_ts
from the IncidentUpdate. -
save
–Custom save method to save each changed key event.
Source code in src/firefighter/incidents/forms/update_key_events.py
get_milestones_with_data ¤
get_milestones_with_data(milestones_definitions: Iterable[MilestoneType]) -> list[MilestoneTypeData]
Get each firefighter.incidents.models.milestone_type.MilestoneType with its event_ts
from the IncidentUpdate.
Source code in src/firefighter/incidents/forms/update_key_events.py
save ¤
Custom save method to save each changed key event.
Source code in src/firefighter/incidents/forms/update_key_events.py
update_roles ¤
Classes:
IncidentUpdateRolesForm ¤
Bases: Form
Methods:
-
save
–Custom save method to save the updated roles.
Source code in src/firefighter/incidents/forms/update_roles.py
save ¤
Custom save method to save the updated roles.
Source code in src/firefighter/incidents/forms/update_roles.py
utils ¤
Classes:
EnumChoiceField ¤
Bases: TypedChoiceField
Methods:
-
to_python
–Return a value from the enum class.
Source code in src/firefighter/incidents/forms/utils.py
to_python ¤
Return a value from the enum class.
Source code in src/firefighter/incidents/forms/utils.py
menus ¤
Functions:
-
user_details_url
–Return a personalized title for our profile menu item.
migrations ¤
Modules:
-
0006_update_group_names
– -
0007_update_component_name
– -
0010_update_components
– -
0013_add_missing_component
–
0006_update_group_names ¤
Functions:
-
get_group_mappings
–Returns the mapping table for updating existing groups.
-
get_new_groups
–Returns a dictionary of new groups to be created.
get_group_mappings ¤
get_group_mappings() -> dict
Returns the mapping table for updating existing groups.
Source code in src/firefighter/incidents/migrations/0006_update_group_names.py
0007_update_component_name ¤
Functions:
-
get_component_mappings
–Returns a list of tuples for updating existing component names and their attributes.
-
get_new_components
–Returns a dictionary of new components to be created.
get_component_mappings ¤
get_component_mappings() -> list
Returns a list of tuples for updating existing component names and their attributes.
Each tuple contains
- old_name (str): The current name of the component.
- new_name (str): The new name to assign to the component.
- slack_channel (str): The associated Slack channel for the component.
- group_name (str): The name of the group to which the component belongs.
Returns:
-
list
(list
) –A list of tuples, each representing the details for a component update.
Source code in src/firefighter/incidents/migrations/0007_update_component_name.py
get_new_components ¤
get_new_components() -> dict
Returns a dictionary of new components to be created.
Each entry in the dictionary maps a component name to a tuple containing: - group_name: The name of the group the component belongs to. - slack_channel: The associated Slack channel for the component.
Returns:
-
dict
(dict
) –A mapping of component names to (group name, slack channel) tuples.
Source code in src/firefighter/incidents/migrations/0007_update_component_name.py
0010_update_components ¤
Functions:
-
get_component_mappings
–Returns a list of tuples for updating existing component names and their attributes.
get_component_mappings ¤
get_component_mappings() -> list
Returns a list of tuples for updating existing component names and their attributes.
Each tuple contains
- old_name (str): The current name of the component.
- new_name (str): The new name to assign to the component.
- slack_channel (str): The associated Slack channel for the component.
- group_name (str): The name of the group to which the component belongs.
Returns:
-
list
(list
) –A list of tuples, each representing the details for a component update.
Source code in src/firefighter/incidents/migrations/0010_update_components.py
0013_add_missing_component ¤
Functions:
-
get_new_components
–Returns a dictionary of new components to be created.
get_new_components ¤
get_new_components() -> dict
Returns a dictionary of new components to be created.
Each entry in the dictionary maps a component name to a tuple containing: - group_name: The name of the group the component belongs to. - slack_channel: The associated Slack channel for the component.
Returns:
-
dict
(dict
) –A mapping of component names to (group name, slack channel) tuples.
Source code in src/firefighter/incidents/migrations/0013_add_missing_component.py
models ¤
Modules:
-
component
– -
group
– -
impact
– -
incident
– -
incident_cost
– -
incident_cost_type
– -
incident_update
– -
milestone_type
–MilestoneType model.
-
priority
– -
user
–
component ¤
Classes:
-
ComponentFilterSet
–Set of filters for Component, share by Web UI and API.
-
ComponentManager
–
ComponentFilterSet ¤
Bases: FilterSet
Set of filters for Component, share by Web UI and API.
Methods:
-
component_search
–Search incidents by title, description, and ID.
component_search staticmethod
¤
Search incidents by title, description, and ID.
Parameters:
-
queryset
(QuerySet[Component]
) –Queryset to search in.
-
_name
(str
) – -
value
(str
) –Value to search for.
Returns:
-
QuerySet[Component]
–QuerySet[Component]: Search results.
Source code in src/firefighter/incidents/models/component.py
ComponentManager ¤
Bases: Manager['Component']
Methods:
-
queryset_with_mtbf
–Returns a queryset of components with an additional
mtbf
field.
queryset_with_mtbf ¤
queryset_with_mtbf(
date_from: datetime,
date_to: datetime,
queryset: QuerySet[Component] | None = None,
metric_type: str = "time_to_fix",
field_name: str = "mtbf",
) -> QuerySet[Component]
Returns a queryset of components with an additional mtbf
field.
Source code in src/firefighter/incidents/models/component.py
group ¤
impact ¤
Classes:
-
Impact
– -
LevelChoices
–
incident ¤
Classes:
-
Incident
– -
IncidentFilterSet
–Set of filters for incidents, shared by Web UI and API.
-
IncidentManager
–
Functions:
-
component_filter_choices_queryset
–Queryset for choices of Components in IncidentFilterSet.
Incident ¤
Bases: Model
Methods:
-
build_invite_list
–Send a Django Signal to get the list of users to invite from different integrations (Slack, Confluence, PagerDuty...).
-
compute_metrics
–Compute all metrics (time to fix, ...) from events.
-
missing_milestones
–Returns all required Milestones still needed to compute the metrics.
-
update_roles
–Update the roles related to an incident, and create an IncidentUpdate.
Attributes:
-
status_page_url
(str
) –Similar with
get_absolute_url
but with full domain, to be used out of the website.
status_page_url property
¤
status_page_url: str
Similar with get_absolute_url
but with full domain, to be used out of the website.
build_invite_list ¤
Send a Django Signal to get the list of users to invite from different integrations (Slack, Confluence, PagerDuty...).
Returns:
Source code in src/firefighter/incidents/models/incident.py
compute_metrics ¤
compute_metrics(*, purge: bool = False) -> None
Compute all metrics (time to fix, ...) from events.
Source code in src/firefighter/incidents/models/incident.py
missing_milestones ¤
Returns all required Milestones still needed to compute the metrics.
Source code in src/firefighter/incidents/models/incident.py
update_roles ¤
update_roles(updater: User, roles_mapping: dict[str, User | None] | dict[str, User]) -> IncidentUpdate
Update the roles related to an incident, and create an IncidentUpdate. For each role, provide a User or None.
This function will update the incident, create an IncidentUpdate, and trigger the incident_updated signal, with update_roles
sender.
Parameters:
-
updater
(User
) –The user who is updating the roles.
-
roles_mapping
(dict[str, User | None]
) –A dict of roles to update, with the new User or None. Defaults to None.
Returns:
-
IncidentUpdate
(IncidentUpdate
) –The created IncidentUpdate with the updated roles.
Source code in src/firefighter/incidents/models/incident.py
IncidentFilterSet ¤
Bases: FilterSet
Set of filters for incidents, shared by Web UI and API.
Methods:
-
incident_search
–Search incidents by title, description, and ID.
incident_search staticmethod
¤
Search incidents by title, description, and ID.
Parameters:
-
queryset
(QuerySet[Incident]
) –Queryset to search in.
-
_name
(str
) – -
value
(str
) –Value to search for.
Returns:
Source code in src/firefighter/incidents/models/incident.py
IncidentManager ¤
Bases: Manager['Incident']
Methods:
-
declare
–Create an Incident and its first IncidentUpdate.
-
search
–Search for incidents using a search term, on the title and description fields.
declare ¤
Create an Incident and its first IncidentUpdate. Send the incident_created signal. Returns the saved incident, no need to .save().
Source code in src/firefighter/incidents/models/incident.py
search staticmethod
¤
Search for incidents using a search term, on the title and description fields.
Parameters:
-
queryset
(QuerySet[Incident] | None
) –Queryset to search in. If None, search in all incidents. The Queryset allows to search on a subset of incidents (already filtered).
-
search_term
(str
) –Search term.
Returns:
-
tuple[QuerySet[Incident], bool]
–tuple[QuerySet[Incident], bool]: Queryset of incidents matching the search term, and a boolean indicating if the search may contain duplicates objects.
Source code in src/firefighter/incidents/models/incident.py
component_filter_choices_queryset ¤
Queryset for choices of Components in IncidentFilterSet. Moved it as a function because models are not loaded when creating filters.
Source code in src/firefighter/incidents/models/incident.py
incident_cost ¤
Classes:
-
IncidentCost
–Incident Cost is inspired from dispatch.
incident_cost_type ¤
Classes:
-
IncidentCostType
–Incident Cost Type is inspired from dispatch.
incident_update ¤
Classes:
-
IncidentUpdate
–IncidentUpdate represents a single update to an incident.
Functions:
-
set_event_ts
–Add a timestamp on every IncidentUpdate.
IncidentUpdate ¤
Bases: Model
IncidentUpdate represents a single update to an incident. One incident can have many incident updates. Only updated fields are stored in the incident update.
set_event_ts ¤
set_event_ts(sender: Any, instance: IncidentUpdate, **kwargs: Any) -> None
Add a timestamp on every IncidentUpdate. Not implemented using Django ORM auto_add as it would not make them user editable.
Source code in src/firefighter/incidents/models/incident_update.py
milestone_type ¤
MilestoneType model.
Classes:
-
MilestoneType
–Represents a milestone type, also known as a key event time or event time.
priority ¤
user ¤
signals ¤
Attributes:
-
create_incident_conversation
–Signal sent to create a conversation for an incident.
-
get_invites
–Signal sent to retrieve the list of users to invite for an incident.
-
incident_closed
–Signal sent when an incident is closed
-
incident_created
–Signal sent when an incident is created
-
incident_key_events_updated
–Signal sent when an incident's key events are updated.
-
incident_updated
–Signal sent when an incident is updated.
-
postmortem_created
–Signal sent when a postmortem is created.
create_incident_conversation module-attribute
¤
create_incident_conversation = Signal()
Signal sent to create a conversation for an incident.
Parameters:
-
incident
(Incident
) –The incident for which to create a conversation.
incident_closed module-attribute
¤
incident_closed = Signal()
Signal sent when an incident is closed
Parameters:
-
sender
(Any
) –The sender of the signal name
-
incident
(Incident
) –The incident that was closed
incident_created module-attribute
¤
incident_created = Signal()
Signal sent when an incident is created
Parameters:
-
incident
(Incident
) –The incident that was created
incident_key_events_updated module-attribute
¤
incident_key_events_updated = Signal()
Signal sent when an incident's key events are updated.
Parameters:
-
incident
(Incident
) –The incident that was updated
incident_updated module-attribute
¤
incident_updated = Signal()
Signal sent when an incident is updated.
Parameters:
-
sender
(str | Any
) –The sender of the signal name
-
incident
(Incident
) –The incident that was updated
-
incident_update
(IncidentUpdate
) –The incident update that was created
-
update_fields
(list[str]
) –The fields that were updated
-
old_priority
(Priority
) –The old priority of the incident (optional kwarg)
tasks ¤
Modules:
updateoncall ¤
Functions:
-
update_oncall
–Fetch current on-calls and update the on-call Slack topic and Confluence page.
-
update_oncall_slack_topic
–TODO(gab) Move in the Slack app.
-
update_oncall_views
–Updates the on-call Slack topic and Confluence page containing the info for the on-call personnel.
update_oncall ¤
Fetch current on-calls and update the on-call Slack topic and Confluence page.
Source code in src/firefighter/incidents/tasks/updateoncall.py
update_oncall_slack_topic ¤
TODO(gab) Move in the Slack app.
Source code in src/firefighter/incidents/tasks/updateoncall.py
update_oncall_views ¤
Updates the on-call Slack topic and Confluence page containing the info for the on-call personnel.
Source code in src/firefighter/incidents/tasks/updateoncall.py
views ¤
Modules:
-
components
– -
date_filter
– -
date_utils
– -
errors
–From Django default errors views.
-
users
– -
views
–
components ¤
Modules:
-
list
–
list ¤
Classes:
ComponentsViewList ¤
Bases: SingleTableMixin
, FilterView
Methods:
-
get_context_data
–No *args to pass.
get_context_data ¤
No *args to pass.
Source code in src/firefighter/incidents/views/components/list.py
date_filter ¤
Functions:
-
get_date_range_from_special_date
–TODO Specify the year parameter (ISO or calendar).
-
parse_moment
–Returns a :class:
slice
with the :func:slice.start
and :func:slice.stop
of the given moment.
get_date_range_from_special_date ¤
get_date_range_from_special_date(unparsed_date: str) -> tuple[datetime | None, datetime | None, str | None, str | None]
TODO Specify the year parameter (ISO or calendar).
Source code in src/firefighter/incidents/views/date_filter.py
parse_moment ¤
Returns a :class:slice
with the :func:slice.start
and :func:slice.stop
of the given moment. If the moment is not a valid moment, returns None. If the moment is a point in time, returns a slice with the same start and stop.
Source code in src/firefighter/incidents/views/date_filter.py
date_utils ¤
Functions:
-
get_bounds_from_calendar_year
–Calendar Year.
-
get_bounds_from_year
–ISO Year.
get_bounds_from_calendar_year ¤
Calendar Year.
Source code in src/firefighter/incidents/views/date_utils.py
get_bounds_from_year ¤
ISO Year.
Source code in src/firefighter/incidents/views/date_utils.py
errors ¤
From Django default errors views. https://github.com/django/django/blob/0dd29209091280ccf34e07c9468746c396b7778e/django/views/defaults.py.
Functions:
-
bad_request
–400 error handler.
-
page_not_found
–Default 404 handler.
-
permission_denied
–Permission denied (403) handler.
-
server_error
–500 error handler.
bad_request ¤
bad_request(request: HttpRequest, exception: Exception, template_name: str = ERROR_400_TEMPLATE_NAME) -> HttpResponse
400 error handler.
Templates: :template:400.html
Context: None
Source code in src/firefighter/incidents/views/errors.py
page_not_found ¤
page_not_found(request: HttpRequest, exception: Exception, template_name: str = ERROR_404_TEMPLATE_NAME) -> HttpResponse
Default 404 handler.
Templates: :template:404.html
Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/'). It's quoted to prevent a content injection attack. exception The message from the exception which triggered the 404 (if one was supplied), or the exception class name
Source code in src/firefighter/incidents/views/errors.py
permission_denied ¤
permission_denied(request: HttpRequest, exception: Exception, template_name: str = ERROR_403_TEMPLATE_NAME) -> HttpResponse
Permission denied (403) handler.
Templates: :template:403.html
Context: exception The message from the exception which triggered the 403 (if one was supplied).
If the template does not exist, an HTTP 403 response containing the text "403 Forbidden" (as per RFC 7231) will be returned.
Source code in src/firefighter/incidents/views/errors.py
server_error ¤
server_error(request: HttpRequest, template_name: str = ERROR_500_TEMPLATE_NAME) -> HttpResponse
500 error handler.
Templates: :template:500.html
Context: None
Source code in src/firefighter/incidents/views/errors.py
users ¤
Modules:
-
details
–
details ¤
Classes:
-
UserDetailView
–In this view, be extra careful.
UserDetailView ¤
Bases: CustomDetailView[User]
In this view, be extra careful.
In this context, user
is the logged_in user and target_user
is the user of the profile being viewed.
views ¤
Classes:
-
DashboardView
– -
IncidentListView
– -
IncidentStatisticsView
– -
IncidentUpdateKeyEventsView
– -
ProcessAfterResponse
–Custom Response, to trigger the Slack workflow after creating the incident and returning HTTP 201.
DashboardView ¤
Bases: ListView[Incident]
Methods:
-
get_context_data
–No *args to pass.
get_context_data ¤
No *args to pass.
Source code in src/firefighter/incidents/views/views.py
IncidentListView ¤
Bases: SingleTableMixin
, FilterView
Methods:
-
get_context_data
–No *args to pass.
get_context_data ¤
No *args to pass.
Source code in src/firefighter/incidents/views/views.py
IncidentStatisticsView ¤
Bases: FilterView
Methods:
-
get_context_data
–No *args to pass.
get_context_data ¤
No *args to pass.
Source code in src/firefighter/incidents/views/views.py
IncidentUpdateKeyEventsView ¤
Bases: SingleObjectMixin[Incident]
, LoginRequiredMixin
, FormView[IncidentUpdateKeyEventsForm]
Methods:
-
get_form
–Replace Markdown bold syntax with HTML bold syntax in form labels.
get_form ¤
get_form(form_class: type[IncidentUpdateKeyEventsForm] | None = None) -> IncidentUpdateKeyEventsForm
Replace Markdown bold syntax with HTML bold syntax in form labels.
Source code in src/firefighter/incidents/views/views.py
ProcessAfterResponse ¤
Bases: HttpResponseRedirect
Custom Response, to trigger the Slack workflow after creating the incident and returning HTTP 201.
TODO This does not work, the workflow is triggered before the response is sent. We need to do a celery task! TODO We need to redirect to the incident page or Slack conversation.