Skip to content

Commit

Permalink
Removes option to delete a signal definition (#5471)
Browse files Browse the repository at this point in the history
* Removes delete dialog for signal definitions

* Removes delete endpoint and related service function

* removes delete test
  • Loading branch information
mvilanova authored Nov 13, 2024
1 parent e7d3468 commit a557071
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 95 deletions.
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)
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 a557071

Please sign in to comment.