Skip to content

Commit

Permalink
Fixes issues with updating case tickets (#3836)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvilanova authored Oct 3, 2023
1 parent 8a056e5 commit b6e22f3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/dispatch/case/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def case_new_create_flow(
# we create the ticket
ticket_flows.create_case_ticket(case=case, db_session=db_session)

# we resolve participants
individual_participants, team_participants = get_case_participants(
case=case, db_session=db_session
)
Expand All @@ -198,6 +199,9 @@ def case_new_create_flow(
team_participants=team_participants,
conversation_target=conversation_target,
)
else:
# we still want to update the ticket, but not twice if resources are created
ticket_flows.update_case_ticket(case=case, db_session=db_session)

if case.case_priority.page_assignee:
if not service_id:
Expand Down Expand Up @@ -341,8 +345,9 @@ def case_update_flow(
db_session=db_session,
)

# we send the case updated notification
update_conversation(case, db_session)
if case.conversation:
# we send the case updated notification
update_conversation(case, db_session)


def case_delete_flow(case: Case, db_session: SessionLocal):
Expand Down Expand Up @@ -654,14 +659,14 @@ def case_create_resources_flow(
db_session=db_session,
)

# we update the ticket
ticket_flows.update_case_ticket(case=case, db_session=db_session)

# we update the case document
document_flows.update_document(
document=case.case_document, project_id=case.project.id, db_session=db_session
)

# we update the ticket
ticket_flows.update_case_ticket(case=case, db_session=db_session)

try:
# we create the conversation and add participants to the thread
conversation_flows.create_case_conversation(case, conversation_target, db_session)
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/case/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def update(*, db_session, case: Case, case_in: CaseUpdate, current_user: Dispatc
db_session=db_session,
source="Dispatch Core App",
description=(
f"Case status changed to {case_in.status.lower()} " f"by {current_user.email}"
f"Case status changed to {case_in.status.lower()} by {current_user.email}"
),
dispatch_user_id=current_user.id,
case_id=case.id,
Expand Down
14 changes: 11 additions & 3 deletions src/dispatch/ticket/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def update_case_ticket(
case: Case,
db_session: SessionLocal,
):
"""Updates an case ticket."""
"""Updates a case ticket."""
plugin = plugin_service.get_active_instance(
db_session=db_session, project_id=case.project.id, plugin_type="ticket"
)
Expand All @@ -215,6 +215,14 @@ def update_case_ticket(
case_type_in=case.case_type,
).get_meta(plugin.plugin.slug)

case_document_weblink = ""
if case.case_document:
case_document_weblink = resolve_attr(case, "case_document.weblink")

case_storage_weblink = ""
if case.storage:
case_storage_weblink = resolve_attr(case, "storage.weblink")

# we update the external case ticket
try:
plugin.instance.update_case_ticket(
Expand All @@ -227,8 +235,8 @@ def update_case_ticket(
case.case_priority.name,
case.status.lower(),
case.assignee.individual.email,
resolve_attr(case, "case_document.weblink"),
resolve_attr(case, "storage.weblink"),
case_document_weblink,
case_storage_weblink,
case_type_plugin_metadata=case_type_plugin_metadata,
)
except Exception as e:
Expand Down

0 comments on commit b6e22f3

Please sign in to comment.