Example #1
0
def update_incident_lead_event(prev_state, instance):
    old_lead = None
    if prev_state.lead:
        old_lead = ExternalUserSerializer(prev_state.lead).data

    new_lead = None
    if instance.lead:
        new_lead = ExternalUserSerializer(instance.lead).data

    if prev_state.lead:
        if instance.lead:
            text = f"Incident lead changed from {prev_state.lead.display_name} to {instance.lead.display_name}"
        else:
            text = f"{prev_state.lead.display_name} was removed as incident lead"

    else:
        text = f"{instance.lead.display_name} was added as incident lead"

    add_incident_update_event(
        incident=instance,
        update_type="incident_lead",
        text=text,
        old_value=old_lead,
        new_value=new_lead,
    )
Example #2
0
def update_incident_report_event(prev_state, instance):
    add_incident_update_event(
        incident=instance,
        update_type="incident_report",
        text=
        f'Incident report updated from "{prev_state.report}" to "{instance.report}"',
        old_value=prev_state.report,
        new_value=instance.report,
    )
Example #3
0
def update_incident_summary_event(prev_state, instance):
    if prev_state.summary:
        text = f'Incident summary updated from "{prev_state.summary}" to "{instance.summary}"'
    else:
        text = f'Incident summary added: "{instance.summary}"'

    add_incident_update_event(
        incident=instance,
        update_type="incident_summary",
        text=text,
        old_value=prev_state.summary,
        new_value=instance.summary,
    )
Example #4
0
def update_incident_impact_event(prev_state, instance):
    if prev_state.impact:
        text = (
            f'Incident impact updated from "{prev_state.impact}" to "{instance.impact}"'
        )
    else:
        text = f'Incident impact added: "{instance.impact}"'

    add_incident_update_event(
        incident=instance,
        update_type="incident_impact",
        text=text,
        old_value=prev_state.impact,
        new_value=instance.impact,
    )
Example #5
0
def update_incident_severity_event(prev_state, instance):
    if prev_state.severity:
        text = f"Incident severity updated from {prev_state.severity_text()} to {instance.severity_text()}"
    else:
        text = f"Incident severity set to {instance.severity_text()}"

    add_incident_update_event(
        incident=instance,
        update_type="incident_severity",
        text=text,
        old_value={
            "id": prev_state.severity,
            "text": prev_state.severity_text() if prev_state else "",
        },
        new_value={
            "id": instance.severity,
            "text": instance.severity_text()
        },
    )