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

Bugfix/tracking sheet #1372

Merged
merged 23 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions docs/admin-guide/administration/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,10 @@ Dispatch [calculates](https://github.com/Netflix/dispatch/blob/develop/src/dispa

> Controls the resource type to use for incident tasks.

#### `INCIDENT_RESOURCE_FAQ_DOCUMENT` \[default: 'google-docs-faq-document'\]

> Controls the resource type to use for the incident faq document.

#### `INCIDENT_RESOURCE_TACTICAL_GROUP` \[default: 'google-group-participant-tactical-group'\]

> Controls the resource type to use for tactical groups.

#### `INCIDENT_RESOURCE_NOTIFICATIONS_GROUP` \[default: 'google-group-participant-notification-group'\]

> Controls the resource type to use for notification groups.

#### `INCIDENT_RESOURCE_INVESTIGATION_DOCUMENT` \[default: 'google-docs-investigation-document'\]

> Controls the resource type to use for the investigation document.

#### `INCIDENT_RESOURCE_INVESTIGATION_SHEET` \[default: 'google-docs-investigation-sheet'\]

> Controls the resource type to use for the investigation sheet.

#### `INCIDENT_RESOURCE_INCIDENT_REVIEW_DOCUMENT` \[default: 'google-docs-incident-review-document'\]

> Controls the resource type to use for the incident review document.
6 changes: 2 additions & 4 deletions src/dispatch/auth/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,13 @@ def create(*, db_session, organization: str, user_in: UserRegister) -> DispatchU
org = organization_service.get_by_slug(db_session=db_session, slug=organization)

# add the user to the default organization
user.organizations.append(
DispatchUserOrganization(organization=org, role=UserRoles.member.value)
)
user.organizations.append(DispatchUserOrganization(organization=org, role=UserRoles.member))

# get the default project
default_project = project_service.get_default(db_session=db_session)

# add the user to the default project
user.projects.append(DispatchUserProject(project=default_project, role=UserRoles.member.value))
user.projects.append(DispatchUserProject(project=default_project, role=UserRoles.member))
db_session.add(user)
db_session.commit()
return user
Expand Down
30 changes: 0 additions & 30 deletions src/dispatch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,36 +212,6 @@ def __str__(self) -> str:
INCIDENT_RESOURCE_NOTIFICATIONS_GROUP = config(
"INCIDENT_RESOURCE_NOTIFICATIONS_GROUP", default="google-group-participant-notifications-group"
)
INCIDENT_RESOURCE_INVESTIGATION_SHEET_TEMPLATE = config(
"INCIDENT_RESOURCE_INVESTIGATION_SHEET_TEMPLATE", default="dispatch-incident-sheet-template"
)
INCIDENT_RESOURCE_INCIDENT_REVIEW_DOCUMENT_TEMPLATE = config(
"INCIDENT_RESOURCE_INCIDENT_REVIEW_DOCUMENT_TEMPLATE",
default="dispatch-incident-review-document-template",
)
INCIDENT_RESOURCE_EXECUTIVE_REPORT_DOCUMENT_TEMPLATE = config(
"INCIDENT_RESOURCE_EXECUTIVE_REPORT_DOCUMENT_TEMPLATE",
default="dispatch-executive-report-document-template",
)
INCIDENT_RESOURCE_INVESTIGATION_DOCUMENT = config(
"INCIDENT_RESOURCE_INVESTIGATION_DOCUMENT", default="dispatch-incident-document"
)
INCIDENT_RESOURCE_INVESTIGATION_SHEET = config(
"INCIDENT_RESOURCE_INVESTIGATION_SHEET", default="dispatch-incident-sheet"
)
INCIDENT_RESOURCE_INCIDENT_REVIEW_DOCUMENT = config(
"INCIDENT_RESOURCE_INCIDENT_REVIEW_DOCUMENT", default="dispatch-incident-review-document"
)
INCIDENT_RESOURCE_EXECUTIVE_REPORT_DOCUMENT = config(
"INCIDENT_RESOURCE_EXECUTIVE_REPORT_DOCUMENT", default="dispatch-executive-report-document"
)
INCIDENT_RESOURCE_CONVERSATION_REFERENCE_DOCUMENT = config(
"INCIDENT_RESOURCE_CONVERSATION_REFERENCE_DOCUMENT",
default="dispatch-conversation-reference-document",
)
INCIDENT_RESOURCE_INCIDENT_FAQ_DOCUMENT = config(
"INCIDENT_RESOURCE_INCIDENT_FAQ_DOCUMENT", default="dispatch-incident-faq-document"
)
INCIDENT_RESOURCE_INCIDENT_TASK = config(
"INCIDENT_RESOURCE_INCIDENT_TASK", default="google-docs-incident-task"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""Adds incident type specific documents.

Revision ID: 875e6b212dc7
Revises: 32811f581cb8
Create Date: 2021-07-01 10:19:24.016062

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "875e6b212dc7"
down_revision = "32811f581cb8"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"incident_type",
"template_document_id",
nullable=True,
new_column_name="incident_template_document_id",
)
op.add_column(
"incident_type", sa.Column("executive_template_document_id", sa.Integer(), nullable=True)
)
op.add_column(
"incident_type", sa.Column("review_template_document_id", sa.Integer(), nullable=True)
)
op.add_column(
"incident_type", sa.Column("tracking_template_document_id", sa.Integer(), nullable=True)
)
op.drop_constraint(
"incident_type_template_document_id_fkey", "incident_type", type_="foreignkey"
)
op.create_foreign_key(
None, "incident_type", "document", ["review_template_document_id"], ["id"]
)
op.create_foreign_key(
None, "incident_type", "document", ["tracking_template_document_id"], ["id"]
)
op.create_foreign_key(
None, "incident_type", "document", ["incident_template_document_id"], ["id"]
)
op.create_foreign_key(
None, "incident_type", "document", ["executive_template_document_id"], ["id"]
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"incident_type",
"incident_template_document_id",
new_column_name="template_document_id",
nullable=True,
)
op.create_foreign_key(
"incident_type_template_document_id_fkey",
"incident_type",
"document",
["template_document_id"],
["id"],
)
op.drop_column("incident_type", "tracking_template_document_id")
op.drop_column("incident_type", "review_template_document_id")
op.drop_column("incident_type", "executive_template_document_id")
op.drop_column("incident_type", "incident_template_document_id")
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion src/dispatch/database/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def restricted_incident_filter(query: orm.Query, current_user: DispatchUser, rol
def restricted_incident_type_filter(query: orm.Query, current_user: DispatchUser):
"""Adds additional incident type filters to query (usually for permissions)."""
if current_user:
query = query.filter(IncidentType.visibility == Visibility.open.value)
query = query.filter(IncidentType.visibility == Visibility.open)
return query


Expand Down
50 changes: 10 additions & 40 deletions src/dispatch/document/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@

from fastapi.encoders import jsonable_encoder

from dispatch.config import (
INCIDENT_RESOURCE_CONVERSATION_REFERENCE_DOCUMENT,
INCIDENT_RESOURCE_EXECUTIVE_REPORT_DOCUMENT_TEMPLATE,
INCIDENT_RESOURCE_INCIDENT_REVIEW_DOCUMENT_TEMPLATE,
INCIDENT_RESOURCE_INVESTIGATION_SHEET_TEMPLATE,
INCIDENT_RESOURCE_INCIDENT_FAQ_DOCUMENT,
)
from dispatch.enums import DocumentResourceTypes
from dispatch.project import service as project_service
from dispatch.search_filter import service as search_filter_service

Expand All @@ -22,58 +16,34 @@ def get(*, db_session, document_id: int) -> Optional[Document]:


def get_by_incident_id_and_resource_type(
*, db_session, incident_id: int, resource_type: str
*, db_session, incident_id: int, project_id: int, resource_type: str
) -> Optional[Document]:
"""Returns a document based on the given incident and id and document resource type."""
return (
db_session.query(Document)
.filter(Document.incident_id == incident_id)
.filter(Document.project_id == project_id)
.filter(Document.resource_type == resource_type)
.one_or_none()
)


def get_conversation_reference_document(*, db_session):
"""Fetches conversation reference document."""
return (
db_session.query(Document).filter(
Document.resource_type == INCIDENT_RESOURCE_CONVERSATION_REFERENCE_DOCUMENT
)
).one_or_none()


def get_executive_report_template(*, db_session):
"""Fetches executive report template document."""
return (
db_session.query(Document).filter(
Document.resource_type == INCIDENT_RESOURCE_EXECUTIVE_REPORT_DOCUMENT_TEMPLATE
)
).one_or_none()


def get_incident_review_template(*, db_session):
"""Fetches incident review template document."""
return (
db_session.query(Document).filter(
Document.resource_type == INCIDENT_RESOURCE_INCIDENT_REVIEW_DOCUMENT_TEMPLATE
)
).one_or_none()


def get_incident_faq_document(*, db_session):
def get_incident_faq_document(*, db_session, project_id: int):
"""Fetches incident faq docment."""
kevgliss marked this conversation as resolved.
Show resolved Hide resolved
return (
db_session.query(Document).filter(
Document.resource_type == INCIDENT_RESOURCE_INCIDENT_FAQ_DOCUMENT
Document.resource_type == DocumentResourceTypes.faq,
Document.project_id == project_id,
)
).one_or_none()


def get_incident_investigation_sheet_template(*, db_session):
"""Fetches incident investigation template sheet."""
def get_conversation_reference_document(*, db_session, project_id: int):
"""Fetches conversation reference document."""
return (
db_session.query(Document).filter(
Document.resource_type == INCIDENT_RESOURCE_INVESTIGATION_SHEET_TEMPLATE
Document.resource_type == DocumentResourceTypes.conversation,
Document.project_id == project_id,
)
).one_or_none()

Expand Down
37 changes: 37 additions & 0 deletions src/dispatch/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class Visibility(str, Enum):
open = "Open"
restricted = "Restricted"

def __str__(self) -> str:
kevgliss marked this conversation as resolved.
Show resolved Hide resolved
return str.__str__(self)


class SearchTypes(str, Enum):
definition = "Definition"
Expand All @@ -21,9 +24,43 @@ class SearchTypes(str, Enum):
team_contact = "TeamContact"
term = "Term"

def __str__(self) -> str:
return str.__str__(self)


class UserRoles(str, Enum):
owner = "Owner"
manager = "Manager"
admin = "Admin"
member = "Member"

def __str__(self) -> str:
return str.__str__(self)


class DocumentResourceTypes(str, Enum):
executive = "dispatch-executive-report-document"
review = "dispatch-incident-review-document"
tracking = "dispatch-incident-sheet"
incident = "dispatch-incident-document"

def __str__(self) -> str:
return str.__str__(self)


class DocumentResourceReferenceTypes(str, Enum):
faq = "dispatch-incident-reference-faq-document"
conversation = "dispatch-conversation-reference-document"

def __str__(self) -> str:
return str.__str__(self)


class DocumentResourceTemplateTypes(str, Enum):
executive = "dispatch-executive-report-document-template"
review = "dispatch-incident-review-document-template"
tracking = "dispatch-incident-sheet-template"
incident = "dispatch-incident-document-template"

def __str__(self) -> str:
return str.__str__(self)
3 changes: 3 additions & 0 deletions src/dispatch/incident/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ class IncidentStatus(str, Enum):
active = "Active"
stable = "Stable"
closed = "Closed"

def __str__(self) -> str:
return str.__str__(self)
Loading