Skip to content

Commit

Permalink
Changing source for custom events and Slack-imported events
Browse files Browse the repository at this point in the history
  • Loading branch information
whitdog47 committed Sep 20, 2023
1 parent 78cae35 commit 9258c70
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/dispatch/incident/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def create_custom_event(
"""Creates a custom event."""
background_tasks.add_task(
report_flows.log_incident_event,
user_email=current_user.email,
incident_id=current_incident.id,
event_in=event_in,
organization_slug=organization,
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def handle_timeline_added_event(
# we log the event
event_service.log_incident_event(
db_session=db_session,
source="Slack Plugin - Conversation Management",
source=f"Slack message from {individual.name}",
description=f'"{message_text}," said {individual.name}',
incident_id=context["subject"].id,
individual_id=individual.id,
Expand Down Expand Up @@ -1043,7 +1043,7 @@ def handle_add_timeline_submission_event(

event_service.log_incident_event(
db_session=db_session,
source="Slack Plugin - Conversation Management",
source=f"Slack message from {participant.individual.name}",
started_at=event_dt_utc,
description=f'"{event_description}," said {participant.individual.name}',
incident_id=context["subject"].id,
Expand Down
9 changes: 8 additions & 1 deletion src/dispatch/report/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from dispatch.exceptions import InvalidConfigurationError
from dispatch.incident import service as incident_service
from dispatch.participant import service as participant_service
from dispatch.individual import service as individual_service
from dispatch.plugin import service as plugin_service
from dispatch.event.models import EventCreate

from .enums import ReportTypes
from .messaging import (
Expand Down Expand Up @@ -82,11 +82,18 @@ def create_tactical_report(

@background_task
def log_incident_event(
user_email: str,
incident_id: int,
event_in: dict,
organization_slug: str = None,
db_session=None,
):
incident = incident_service.get(db_session=db_session, incident_id=incident_id)
individual = individual_service.get_by_email_and_project(
db_session=db_session, email=user_email, project_id=incident.project.id
)
event_in["source"] = f"Custom event created by {individual.name}"

event_service.log_incident_event(
db_session=db_session,
source=event_in["source"],
Expand Down
9 changes: 8 additions & 1 deletion src/dispatch/static/dispatch/src/incident/TimelineTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
>
<div class="horiz-rule" />
<div class="add-button">
<v-btn compact small plain class="up-button">
<v-btn
compact
small
plain
class="up-button"
@click="showNewPreEventDialog(sortedEvents[0].started_at)"
>
<v-icon small class="mr-1">mdi-plus-circle-outline</v-icon>Add event
</v-btn>
</div>
Expand Down Expand Up @@ -153,6 +159,7 @@ export default {
"showNewEventDialog",
"showEditEventDialog",
"showDeleteEventDialog",
"showNewPreEventDialog",
]),
exportToCSV() {
this.exportLoading = true
Expand Down
10 changes: 9 additions & 1 deletion src/dispatch/static/dispatch/src/incident/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import SearchUtils from "@/search/utils"
import IncidentApi from "@/incident/api"
import router from "@/router"

import moment from "moment-timezone"

const getDefaultSelectedState = () => {
return {
cases: [],
Expand Down Expand Up @@ -249,8 +251,14 @@ const actions = {
closeEditEventDialog({ commit }) {
commit("SET_DIALOG_EDIT_EVENT", false)
},
showNewPreEventDialog({ commit }, started_at) {
started_at = moment(started_at).subtract(1, "seconds").toISOString()
state.selected.currentEvent = { started_at, description: "" }
commit("SET_DIALOG_EDIT_EVENT", true)
},
showNewEventDialog({ commit }, started_at) {
state.selected.currentEvent = { started_at }
started_at = moment(started_at).add(1, "seconds").toISOString()
state.selected.currentEvent = { started_at, description: "" }
commit("SET_DIALOG_EDIT_EVENT", true)
},
showDeleteEventDialog({ commit }, event) {
Expand Down

0 comments on commit 9258c70

Please sign in to comment.