incidents ¤
admin ¤
EnvironmentAdmin ¤
Bases: ModelAdmin[Environment]
get_readonly_fields ¤
Deny changing the value of an existing object.
Source code in src/firefighter/incidents/admin.py
IncidentAdmin ¤
Bases: ModelAdmin[Incident]
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 ¤
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).
factories ¤
forms ¤
close_incident ¤
create_incident ¤
select_impact ¤
SelectImpactForm ¤
Bases: Form
Source code in src/firefighter/incidents/forms/select_impact.py
business_impact_new
property
¤
Get business impact. Will return N/A, Low, Medium or High.
save ¤
Save the impact choices to the incident.
Source code in src/firefighter/incidents/forms/select_impact.py
suggest_priority_from_impact ¤
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 ¤
IncidentUpdateKeyEventsForm ¤
Bases: Form
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 ¤
IncidentUpdateRolesForm ¤
Bases: Form
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
update_status ¤
utils ¤
EnumChoiceField ¤
Bases: TypedChoiceField
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 ¤
user_details_url ¤
Return a personalized title for our profile menu item.
Source code in src/firefighter/incidents/menus.py
models ¤
component ¤
ComponentFilterSet ¤
Bases: FilterSet
Set of filters for Component, share by Web UI and API.
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']
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
impact ¤
incident ¤
Incident ¤
Bases: Model
status_page_url
property
¤
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 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.
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']
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_membership ¤
incident_update ¤
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 ¤
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
metric_type ¤
milestone_type ¤
user ¤
User ¤
Bases: AbstractUser
full_name
property
¤
User full name (first + last name). Looks for the first_name and last_name fields, then name, then username. Will return an empty string if none of these are set.
signals ¤
create_incident_conversation
module-attribute
¤
Signal sent to create a conversation for an incident.
Parameters:
-
incident
(Incident
) –The incident for which to create a conversation.
get_invites
module-attribute
¤
incident_closed
module-attribute
¤
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
¤
Signal sent when an incident is created
Parameters:
-
incident
(Incident
) –The incident that was created
incident_key_events_updated
module-attribute
¤
Signal sent when an incident's key events are updated.
Parameters:
-
incident
(Incident
) –The incident that was updated
incident_updated
module-attribute
¤
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)
new_qualifier
module-attribute
¤
Signal sent when a new qualifier.
tables ¤
tasks ¤
updateoncall ¤
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
urls ¤
views ¤
components ¤
details ¤
list ¤
ComponentsViewList ¤
Bases: SingleTableMixin
, FilterView
get_context_data ¤
No *args to pass.
Source code in src/firefighter/incidents/views/components/list.py
date_filter ¤
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 ¤
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.
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 ¤
500 error handler.
Templates: :template:500.html
Context: None
Source code in src/firefighter/incidents/views/errors.py
reports ¤
users ¤
details ¤
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 ¤
DashboardView ¤
IncidentListView ¤
Bases: SingleTableMixin
, FilterView
get_context_data ¤
No *args to pass.
Source code in src/firefighter/incidents/views/views.py
IncidentStatisticsView ¤
Bases: FilterView
get_context_data ¤
No *args to pass.
Source code in src/firefighter/incidents/views/views.py
IncidentUpdateKeyEventsView ¤
Bases: SingleObjectMixin[Incident]
, LoginRequiredMixin
, FormView[IncidentUpdateKeyEventsForm]
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.