Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/reflect-case-escalation-in-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
whitdog47 authored Nov 13, 2024
2 parents 22d687c + a557071 commit b71a1bf
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 108 deletions.
17 changes: 9 additions & 8 deletions src/dispatch/case/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,15 @@ def common_escalate_flow(
db_session.add(incident)
db_session.commit()

# we run the incident create flow in a background task
incident = incident_flows.incident_create_flow(
incident_id=incident.id,
organization_slug=organization_slug,
db_session=db_session,
case_id=case.id,
)

# we link the case to the incident
case.incidents.append(incident)
db_session.add(case)
db_session.commit()
Expand All @@ -755,14 +764,6 @@ def common_escalate_flow(
case_id=case.id,
)

# we run the incident create flow in a background task
incident = incident_flows.incident_create_flow(
incident_id=incident.id,
organization_slug=organization_slug,
db_session=db_session,
case_id=case.id,
)

# we add the case participants to the incident
for participant in case.participants:
# check to see if already a participant in the incident
Expand Down
7 changes: 5 additions & 2 deletions src/dispatch/database/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def search_filter_sort_paginate(
db_session,
model,
query_str: str = None,
filter_spec: str = None,
filter_spec: str | dict | None = None,
page: int = 1,
items_per_page: int = 5,
sort_by: List[str] = None,
Expand All @@ -558,7 +558,10 @@ def search_filter_sort_paginate(

tag_all_filters = []
if filter_spec:
filter_spec = json.loads(filter_spec)
# some functions pass filter_spec as dictionary such as auth/views.py/get_users
# but most come from API as seraialized JSON
if isinstance(filter_spec, str):
filter_spec = json.loads(filter_spec)
query = apply_filter_specific_joins(model_cls, filter_spec, query)
# if the filter_spec has the TagAll filter, we need to split the query up
# and intersect all of the results
Expand Down
8 changes: 0 additions & 8 deletions src/dispatch/signal/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,6 @@ def update(*, db_session: Session, signal: Signal, signal_in: SignalUpdate) -> S
return signal


def delete(*, db_session: Session, signal_id: int):
"""Deletes a signal definition."""
signal = db_session.query(Signal).filter(Signal.id == signal_id).one()
db_session.delete(signal)
db_session.commit()
return signal_id


def is_valid_uuid(val):
try:
uuid.UUID(str(val), version=4)
Expand Down
17 changes: 0 additions & 17 deletions src/dispatch/signal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
create,
create_signal_engagement,
create_signal_filter,
delete,
delete_signal_filter,
get,
get_by_primary_or_external_id,
Expand Down Expand Up @@ -330,19 +329,3 @@ def update_signal(
) from None

return signal


@router.delete(
"/{signal_id}",
response_model=None,
dependencies=[Depends(PermissionsDependency([SensitiveProjectActionPermission]))],
)
def delete_signal(db_session: DbSession, signal_id: Union[str, PrimaryKey]):
"""Deletes a signal."""
signal = get_by_primary_or_external_id(db_session=db_session, signal_id=signal_id)
if not signal:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=[{"msg": "A signal with this id does not exist."}],
)
delete(db_session=db_session, signal_id=signal.id)
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
<v-card-title class="text-subtitle-1">Needs</v-card-title>
<v-card-text>{{ event.details.needs }}</v-card-text>
</v-card>
<div class="text-caption">
{{ event.source }}
</div>
</v-col>
<v-col class="text-right" cols="4">
<v-tooltip location="bottom">
Expand Down
35 changes: 0 additions & 35 deletions src/dispatch/static/dispatch/src/signal/DeleteDialog.vue

This file was deleted.

8 changes: 2 additions & 6 deletions src/dispatch/static/dispatch/src/signal/Table.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<v-container fluid>
<new-edit-dialog />
<delete-dialog />
<v-row no-gutters>
<v-col>
<v-alert closable icon="mdi-school" prominent text type="info">
Expand Down Expand Up @@ -88,9 +87,6 @@
<v-list-item @click="createEditShow(item)">
<v-list-item-title>View / Edit</v-list-item-title>
</v-list-item>
<v-list-item @click="removeShow(item)">
<v-list-item-title>Delete</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</template>
Expand All @@ -104,12 +100,12 @@
<script>
import { mapFields } from "vuex-map-fields"
import { mapActions } from "vuex"
import NewEditDialog from "@/signal/NewEditDialog.vue"
import DeleteDialog from "@/signal/DeleteDialog.vue"
export default {
name: "SignalTable",
components: { NewEditDialog, DeleteDialog },
components: { NewEditDialog },
props: {
name: {
type: String,
Expand Down
55 changes: 26 additions & 29 deletions tests/signal/test_signal_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_update(session, project, signal):


def test_update__add_filter(session, signal, signal_filter):
from dispatch.signal.models import SignalUpdate, SignalFilterRead
from dispatch.signal.models import SignalFilterRead, SignalUpdate
from dispatch.signal.service import update

signal_filter.project = signal.project
Expand Down Expand Up @@ -91,21 +91,15 @@ def test_update__delete_filter(session, signal, signal_filter):
assert len(signal.filters) == 0


def test_delete(session, signal):
from dispatch.signal.service import delete, get

delete(db_session=session, signal_id=signal.id)
assert not get(db_session=session, signal_id=signal.id)


def test_filter_actions_default_deduplicate(session, signal, project):
from dispatch.signal.models import SignalInstance, SignalFilterAction
from dispatch.signal.service import filter_signal
from dispatch.entity_type.models import EntityType
from datetime import datetime, timedelta

from dispatch.case.models import Case
from dispatch.entity.models import Entity
from dispatch.entity_type.models import EntityType
from dispatch.enums import Visibility
from dispatch.case.models import Case
from datetime import datetime, timedelta
from dispatch.signal.models import SignalFilterAction, SignalInstance
from dispatch.signal.service import filter_signal

entity_type = EntityType(
name="default_dedupe",
Expand Down Expand Up @@ -163,14 +157,14 @@ def test_filter_actions_default_deduplicate(session, signal, project):


def test_filter_actions_deduplicate_different_entities(session, signal, project):
from dispatch.entity.models import Entity
from dispatch.entity_type.models import EntityType
from dispatch.signal.models import (
SignalFilter,
SignalInstance,
SignalFilterAction,
SignalInstance,
)
from dispatch.signal.service import filter_signal
from dispatch.entity_type.models import EntityType
from dispatch.entity.models import Entity

entity_type_0 = EntityType(
name="dedupe2-0",
Expand Down Expand Up @@ -216,14 +210,14 @@ def test_filter_actions_deduplicate_different_entities(session, signal, project)


def test_filter_actions_deduplicate_different_entities_types(session, signal, project):
from dispatch.entity.models import Entity
from dispatch.entity_type.models import EntityType
from dispatch.signal.models import (
SignalFilter,
SignalInstance,
SignalFilterAction,
SignalInstance,
)
from dispatch.signal.service import filter_signal
from dispatch.entity_type.models import EntityType
from dispatch.entity.models import Entity

entity_type_0 = EntityType(
name="dedupe0-0",
Expand Down Expand Up @@ -274,14 +268,14 @@ def test_filter_actions_deduplicate_different_entities_types(session, signal, pr


def test_filter_actions_deduplicate(session, signal, project):
from dispatch.entity.models import Entity
from dispatch.entity_type.models import EntityType
from dispatch.signal.models import (
SignalFilter,
SignalInstance,
SignalFilterAction,
SignalInstance,
)
from dispatch.signal.service import filter_signal
from dispatch.entity_type.models import EntityType
from dispatch.entity.models import Entity

entity_type = EntityType(
name="dedupe1",
Expand Down Expand Up @@ -325,14 +319,15 @@ def test_filter_actions_deduplicate(session, signal, project):

def test_filter_action_with_dedupe_and_snooze(session, signal, project):
from datetime import datetime, timedelta, timezone

from dispatch.entity.models import Entity
from dispatch.entity_type.models import EntityType
from dispatch.signal.models import (
SignalFilter,
SignalInstance,
SignalFilterAction,
SignalInstance,
)
from dispatch.signal.service import filter_signal
from dispatch.entity_type.models import EntityType
from dispatch.entity.models import Entity

entity_type = EntityType(
name="dedupe1+snooze",
Expand Down Expand Up @@ -386,13 +381,14 @@ def test_filter_action_with_dedupe_and_snooze(session, signal, project):

def test_filter_actions_snooze(session, entity, signal, project):
from datetime import datetime, timedelta, timezone

from dispatch.entity_type.models import EntityType
from dispatch.signal.models import (
SignalFilter,
SignalInstance,
SignalFilterAction,
SignalInstance,
)
from dispatch.signal.service import filter_signal
from dispatch.entity_type.models import EntityType

entity_type = EntityType(
name="test",
Expand Down Expand Up @@ -430,13 +426,14 @@ def test_filter_actions_snooze(session, entity, signal, project):

def test_filter_actions_snooze_expired(session, entity, signal, project):
from datetime import datetime, timedelta, timezone

from dispatch.entity_type.models import EntityType
from dispatch.signal.models import (
SignalFilter,
SignalInstance,
SignalFilterAction,
SignalInstance,
)
from dispatch.signal.service import filter_signal
from dispatch.entity_type.models import EntityType

entity_type = EntityType(
name="test",
Expand Down

0 comments on commit b71a1bf

Please sign in to comment.