Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement/page_case_assignee #2778

Merged
merged 9 commits into from
Dec 21, 2022
21 changes: 21 additions & 0 deletions src/dispatch/case/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from dispatch.individual.models import IndividualContactRead
from dispatch.models import OrganizationSlug, PrimaryKey
from dispatch.participant.models import ParticipantUpdate
from dispatch.plugin import service as plugin_service
from dispatch.storage import flows as storage_flows
from dispatch.storage.enums import StorageAction
from dispatch.ticket import flows as ticket_flows
Expand Down Expand Up @@ -106,6 +107,26 @@ def case_new_create_flow(*, case_id: int, organization_slug: OrganizationSlug, d
document=document, project_id=case.project.id, db_session=db_session
)

if case.case_priority.page_assignee:
if case.case_type.oncall_service:
service_id = case.case_type.oncall_service.external_id
oncall_plugin = plugin_service.get_active_instance(
db_session=db_session, project_id=case.project.id, plugin_type="oncall"
)
if oncall_plugin:
oncall_plugin.instance.page(
service_id=service_id,
incident_name=case.name,
incident_title=case.title,
incident_description=case.description,
)
else:
log.warning("Case assignee not paged. No plugin of type oncall enabled.")
else:
log.warning(
"Case assignee not paged. No relationship between case type and an oncall service."
)

# TODO(mvilanova): we send the case created notification

db_session.add(case)
Expand Down
5 changes: 5 additions & 0 deletions src/dispatch/case/priority/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "This case should be triaged on a best-effort basis.",
"view_order": 1,
"color": "#8bc34a",
"page_assignee": False,
"default": True,
"enabled": True,
},
Expand All @@ -12,6 +13,7 @@
"description": "This case should be triaged within 24hrs of case creation.",
"view_order": 2,
"color": "#ffeb3b",
"page_assignee": False,
"default": False,
"enabled": True,
},
Expand All @@ -20,6 +22,7 @@
"description": "This case should be triaged within 8hrs of case creation.",
"view_order": 3,
"color": "#ff9800",
"page_assignee": False,
"default": False,
"enabled": True,
},
Expand All @@ -28,6 +31,7 @@
"description": "This case should be triaged immediately.",
"view_order": 4,
"color": "#e53935",
"page_assignee": True,
"default": False,
"enabled": True,
},
Expand All @@ -36,6 +40,7 @@
"description": "Triage of this case is optional.",
"view_order": 5,
"color": "#9e9e9e",
"page_assignee": False,
"default": False,
"enabled": True,
},
Expand Down
4 changes: 3 additions & 1 deletion src/dispatch/case/priority/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import List, Optional
from pydantic import Field
from pydantic import StrictBool, Field
from pydantic.color import Color

from sqlalchemy import Column, Integer, String, Boolean
Expand All @@ -17,6 +17,7 @@ class CasePriority(Base, ProjectMixin):
id = Column(Integer, primary_key=True)
name = Column(String)
description = Column(String)
page_assignee = Column(Boolean, default=False)
color = Column(String)
enabled = Column(Boolean, default=True)
default = Column(Boolean, default=False)
Expand All @@ -35,6 +36,7 @@ class CasePriority(Base, ProjectMixin):
class CasePriorityBase(DispatchBase):
color: Optional[Color] = Field(None, nullable=True)
default: Optional[bool]
page_assignee: Optional[StrictBool]
description: Optional[str] = Field(None, nullable=True)
enabled: Optional[bool]
name: NameStr
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Adds page_assignee column

Revision ID: bd61c1e1e7cd
Revises: f809d9e76ba3
Create Date: 2022-12-15 14:59:25.077450

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "bd61c1e1e7cd"
down_revision = "f809d9e76ba3"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("case_priority", sa.Column("page_assignee", sa.Boolean(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("case_priority", "page_assignee")
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions src/dispatch/project/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def project_create_flow(*, organization_slug: str, project_id: int, db_session=N
case_priority_in = CasePriorityCreate(
name=priority["name"],
description=priority["description"],
page_assignee=priority["page_assignee"],
project=project,
default=priority["default"],
enabled=priority["enabled"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@
/>
</ValidationProvider>
</v-flex>
<v-flex xs12>
<v-checkbox
v-model="page_assignee"
label="Page Assignee"
hint="Would you like Dispatch to page the case assignee on case creation?"
/>
</v-flex>
<v-flex xs12>
<color-picker-input label="Color" v-model="color"></color-picker-input>
</v-flex>
Expand Down Expand Up @@ -133,6 +140,7 @@ export default {
"selected.id",
"selected.loading",
"selected.name",
"selected.page_assignee",
"selected.project",
"selected.view_order",
]),
Expand Down
4 changes: 4 additions & 0 deletions src/dispatch/static/dispatch/src/case/priority/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
:loading="loading"
loading-text="Loading... Please wait"
>
<template v-slot:item.page_assignee="{ item }">
<v-simple-checkbox v-model="item.page_assignee" disabled />
</template>
<template v-slot:item.default="{ item }">
<v-simple-checkbox v-model="item.default" disabled />
</template>
Expand Down Expand Up @@ -88,6 +91,7 @@ export default {
headers: [
{ text: "Name", value: "name", sortable: true },
{ text: "Description", value: "description", sortable: false },
{ text: "Page Assignee", value: "page_assignee", sortable: true },
{ text: "Default", value: "default", sortable: true },
{ text: "Enabled", value: "enabled", sortable: true },
{ text: "View Order", value: "view_order", sortable: true },
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/static/dispatch/src/case/priority/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const getDefaultSelectedState = () => {
color: null,
default: false,
description: null,
page_assignee: null,
enabled: false,
id: null,
loading: false,
Expand Down