|
1 | 1 | import logging |
2 | 2 | from datetime import datetime |
3 | | -import inspect |
4 | 3 | from typing import Any |
5 | | -import time |
6 | 4 |
|
7 | 5 | import pytz |
8 | 6 | from blockkit import ( |
@@ -1718,34 +1716,46 @@ def handle_report_executive_submission_event( |
1718 | 1716 | form_data: dict, |
1719 | 1717 | user: DispatchUser, |
1720 | 1718 | ) -> None: |
1721 | | - """Handles the report executive submission""" |
| 1719 | + """Handles the report executive submission.""" |
1722 | 1720 | ack_report_executive_submission_event(ack=ack) |
| 1721 | + |
| 1722 | + incident = incident_service.get(db_session=db_session, incident_id=context["subject"].id) |
| 1723 | + |
1723 | 1724 | executive_report_in = ExecutiveReportCreate( |
1724 | 1725 | current_status=form_data[ReportExecutiveBlockIds.current_status], |
1725 | 1726 | overview=form_data[ReportExecutiveBlockIds.overview], |
1726 | 1727 | next_steps=form_data[ReportExecutiveBlockIds.next_steps], |
1727 | 1728 | ) |
1728 | 1729 |
|
1729 | | - incident = incident_service.get(db_session=db_session, incident_id=context["subject"].id) |
1730 | | - |
1731 | 1730 | executive_report = report_flows.create_executive_report( |
1732 | 1731 | user_email=user.email, |
1733 | | - incident_id=context["subject"].id, |
| 1732 | + incident_id=incident.id, |
1734 | 1733 | executive_report_in=executive_report_in, |
1735 | 1734 | organization_slug=context["subject"].organization_slug, |
1736 | 1735 | ) |
1737 | 1736 |
|
1738 | | - modal = Modal( |
1739 | | - title="Executive Report", |
1740 | | - blocks=[ |
| 1737 | + blocks = [] |
| 1738 | + if executive_report and incident.notifications_group: |
| 1739 | + blocks = [ |
1741 | 1740 | Section(text="Creating executive report... Success!"), |
1742 | 1741 | Section( |
1743 | 1742 | text=f"The executive report document has been created and can be found in the incident storage here: {executive_report.document.weblink}" |
1744 | 1743 | ), |
1745 | 1744 | Section( |
1746 | | - text=f"The executive report has been emailed to the incident notifications group ({incident.notifications_group.email}).", |
| 1745 | + text=f"The executive report has been emailed to the incident notifications group: {incident.notifications_group.email}", |
1747 | 1746 | ), |
1748 | | - ], |
| 1747 | + ] |
| 1748 | + else: |
| 1749 | + blocks = [ |
| 1750 | + Section(text="Creating executive report... Failed!"), |
| 1751 | + Section( |
| 1752 | + text="The executive report document was not created successfully or the incident notifications group does not exist." |
| 1753 | + ), |
| 1754 | + ] |
| 1755 | + |
| 1756 | + modal = Modal( |
| 1757 | + title="Executive Report", |
| 1758 | + blocks=blocks, |
1749 | 1759 | close="Close", |
1750 | 1760 | ).build() |
1751 | 1761 |
|
|
0 commit comments