Skip to content

Commit

Permalink
Merge branch 'master' into enhancement/build-with-vite
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgliss authored Oct 31, 2022
2 parents 83fa7fa + ecbad47 commit c8121b6
Show file tree
Hide file tree
Showing 90 changed files with 2,674 additions and 2,428 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ src/dispatch/static/test/e2e/reports/
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

Expand Down
2 changes: 1 addition & 1 deletion requirements-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ six==1.16.0
# python-multipart
# sqlalchemy-filters
# validators
slack-sdk==3.19.1
slack-sdk==3.19.2
# via -r requirements-base.in
smart-open==5.2.1
# via pathy
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ flake8==4.0.1
# via -r requirements-dev.in
iniconfig==1.1.1
# via pytest
ipython==8.5.0
ipython==8.6.0
# via -r requirements-dev.in
jedi==0.18.1
# via ipython
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,13 @@ def run(self):
"github_monitor = dispatch.plugins.dispatch_github.plugin:GithubMonitorPlugin",
"google_calendar_conference = dispatch.plugins.dispatch_google.calendar.plugin:GoogleCalendarConferencePlugin",
"google_docs_document = dispatch.plugins.dispatch_google.docs.plugin:GoogleDocsDocumentPlugin",
"google_sheets_signal = dispatch.plugins.dispatch_google.sheets.plugin:GoogleSheetsSignalConsumerPlugin",
"google_drive_storage = dispatch.plugins.dispatch_google.drive.plugin:GoogleDriveStoragePlugin",
"google_drive_task = dispatch.plugins.dispatch_google.drive.plugin:GoogleDriveTaskPlugin",
"google_gmail_email = dispatch.plugins.dispatch_google.gmail.plugin:GoogleGmailEmailPlugin",
"google_groups_participants = dispatch.plugins.dispatch_google.groups.plugin:GoogleGroupParticipantGroupPlugin",
"jira_ticket = dispatch.plugins.dispatch_jira.plugin:JiraTicketPlugin",
"opsgenie_oncall = dispatch.plugins.dispatch_opsgenie.plugin:OpsGenieOncallPlugin",
"pagerduty_oncall = dispatch.plugins.dispatch_pagerduty.plugin:PagerDutyOncallPlugin",
"uptycs_signal = dispatch.plugins.dispatch_uptycs.plugin:UptycsSignalConsumerPlugin",
"slack_contact = dispatch.plugins.dispatch_slack.plugin:SlackContactPlugin",
"slack_conversation = dispatch.plugins.dispatch_slack.plugin:SlackConversationPlugin",
"zoom_conference = dispatch.plugins.dispatch_zoom.plugin:ZoomConferencePlugin",
Expand Down
6 changes: 0 additions & 6 deletions src/dispatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@
from dispatch.case.severity.models import CaseSeverity # noqa lgtm[py/unused-import]
from dispatch.case.type.models import CaseType # noqa lgtm[py/unused-import]
from dispatch.signal.models import Signal # noqa lgtm[py/unused-import]
from dispatch.signal.duplication_rule.models import (
DuplicationRule,
) # noqa lgtm[py/unused-import]
from dispatch.signal.suppression_rule.models import (
SuppressionRule,
) # noqa lgtm[py/unused-import]
except Exception:
traceback.print_exc()

Expand Down
12 changes: 3 additions & 9 deletions src/dispatch/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
from dispatch.plugin.views import router as plugin_router
from dispatch.project.views import router as project_router


from dispatch.signal.views import router as signal_router

# from dispatch.route.views import router as route_router
from dispatch.search.views import router as search_router
from dispatch.search_filter.views import router as search_filter_router
from dispatch.service.views import router as service_router
from dispatch.signal.duplication_rule.views import router as signal_duplication_rule_router
from dispatch.signal.suppression_rule.views import router as signal_suppression_rule_router
from dispatch.signal.views import router as signal_router
from dispatch.tag.views import router as tag_router
from dispatch.tag_type.views import router as tag_type_router
from dispatch.task.views import router as task_router
Expand Down Expand Up @@ -127,12 +127,6 @@ def get_organization_path(organization: OrganizationSlug):
authenticated_organization_api_router.include_router(
signal_router, prefix="/signals", tags="signals"
)
authenticated_organization_api_router.include_router(
signal_duplication_rule_router, prefix="/signals/duplication/rules", tags="duplication_rules"
)
authenticated_organization_api_router.include_router(
signal_suppression_rule_router, prefix="/signals/suppression/rules", tags="suppression_rules"
)

authenticated_organization_api_router.include_router(user_router, prefix="/users", tags=["users"])
authenticated_organization_api_router.include_router(
Expand Down
18 changes: 8 additions & 10 deletions src/dispatch/case/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,18 @@ def case_new_create_flow(*, case_id: int, organization_slug: OrganizationSlug, d
db_session=db_session,
)

if not group:
# we delete the ticket
ticket_flows.delete_ticket(ticket=ticket, db_session=db_session)
# if not group:
# we delete the ticket
# ticket_flows.delete_ticket(ticket=ticket, db_session=db_session)

# we delete the case
delete(db_session=db_session, case_id=case_id)
# we delete the case
# delete(db_session=db_session, case_id=case_id)

return
# return

# we create the storage folder
storage_members = [group.email]
storage = storage_flows.create_storage(
obj=case, storage_members=storage_members, db_session=db_session
)
# storage_members = [group.email]
storage = storage_flows.create_storage(obj=case, storage_members=[], db_session=db_session)
if not storage:
# we delete the group
group_flows.delete_group(group=group, db_session=db_session)
Expand Down
9 changes: 7 additions & 2 deletions src/dispatch/case/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from dispatch.storage.models import StorageRead
from dispatch.tag.models import TagRead
from dispatch.ticket.models import TicketRead
from dispatch.workflow.models import WorkflowInstanceRead
from dispatch.signal.models import SignalRead

from .enums import CaseStatus
Expand Down Expand Up @@ -111,6 +112,10 @@ class Case(Base, TimeStampMixin, ProjectMixin):
tactical_group_id = Column(Integer, ForeignKey("group.id"))
tactical_group = relationship("Group", foreign_keys=[tactical_group_id])

workflow_instances = relationship(
"WorkflowInstance", backref="case", cascade="all, delete-orphan"
)

related_id = Column(Integer, ForeignKey("case.id"))
related = relationship("Case", remote_side=[id], uselist=True, foreign_keys=[related_id])

Expand All @@ -123,7 +128,6 @@ class Case(Base, TimeStampMixin, ProjectMixin):
)

ticket = relationship("Ticket", uselist=False, backref="case", cascade="all, delete-orphan")
signals = relationship("Signal", backref="case")


class ProjectRead(DispatchBase):
Expand Down Expand Up @@ -189,7 +193,7 @@ class CaseRead(CaseBase):
duplicates: Optional[List[CaseReadNested]] = []
escalated_at: Optional[datetime] = None
events: Optional[List[EventRead]] = []
signals: Optional[List[SignalRead]] = []
# signals: Optional[List[SignalRead]] = []
groups: Optional[List[GroupRead]] = []
incidents: Optional[List[IncidentRead]] = []
name: Optional[NameStr]
Expand All @@ -200,6 +204,7 @@ class CaseRead(CaseBase):
tags: Optional[List[TagRead]] = []
ticket: Optional[TicketRead] = None
triage_at: Optional[datetime] = None
workflow_instances: Optional[List[WorkflowInstanceRead]] = []


class CaseUpdate(CaseBase):
Expand Down
7 changes: 3 additions & 4 deletions src/dispatch/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def install_plugins(force):
record = plugin_service.get_by_slug(db_session=db_session, slug=p.slug)
if not record:
click.secho(f"Installing plugin... Slug: {p.slug} Version: {p.version}", fg="blue")
record = Plugin(
plugin = Plugin(
title=p.title,
slug=p.slug,
type=p.type,
Expand All @@ -99,6 +99,7 @@ def install_plugins(force):
multiple=p.multiple,
description=p.description,
)
db_session.add(plugin)
else:
if force:
click.secho(f"Updating plugin... Slug: {p.slug} Version: {p.version}", fg="blue")
Expand All @@ -110,7 +111,6 @@ def install_plugins(force):
record.description = p.description
record.type = p.type

db_session.add(record)
db_session.commit()


Expand Down Expand Up @@ -606,8 +606,7 @@ def dispatch_scheduler():
) # noqa
from .term.scheduled import sync_terms # noqa
from .workflow.scheduled import (
daily_sync_workflow, # noqa
sync_active_stable_workflows, # noqa
sync_workflow, # noqa
)
from .monitor.scheduled import sync_active_stable_monitors # noqa
from .data.source.scheduled import sync_sources # noqa
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __str__(self) -> str:
ENV_TAG_LIST = config("ENV_TAGS", cast=CommaSeparatedStrings, default="")
ENV_TAGS = get_env_tags(ENV_TAG_LIST)

DISPATCH_UI_URL = config("DISPATCH_UI_URL", default="http://localhost:8000")
DISPATCH_UI_URL = config("DISPATCH_UI_URL", default="http://localhost:8080")
DISPATCH_ENCRYPTION_KEY = config("DISPATCH_ENCRYPTION_KEY", cast=Secret)

# authentication
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Adds the ability to associate cases to workflow instances.
Revision ID: cfde1bca6a6e
Revises: e49209df586d
Create Date: 2022-09-23 11:36:09.154783
"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "cfde1bca6a6e"
down_revision = "e49209df586d"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("workflow_instance", sa.Column("case_id", sa.Integer(), nullable=True))
op.create_foreign_key(
None, "workflow_instance", "case", ["case_id"], ["id"], ondelete="CASCADE"
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, "workflow_instance", type_="foreignkey")
op.drop_column("workflow_instance", "case_id")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Merge revision
Revision ID: 3a5e776ddce4
Revises: cfde1bca6a6e, c1abb0cc40e5
Create Date: 2022-10-04 08:54:16.613236
"""

# revision identifiers, used by Alembic.
revision = "3a5e776ddce4"
down_revision = ("c1abb0cc40e5", "cfde1bca6a6e")
branch_labels = None
depends_on = None


def upgrade():
pass


def downgrade():
pass
Loading

0 comments on commit c8121b6

Please sign in to comment.