def create_executive_report( *, db_session: Session = Depends(get_db), current_incident: Incident = Depends(get_current_incident), executive_report_in: ExecutiveReportCreate, current_user: DispatchUser = Depends(get_current_user), background_tasks: BackgroundTasks, ): """ Creates a new executive report. """ background_tasks.add_task( report_flows.create_executive_report( user_email=current_user.email, incident_id=current_incident.id, executive_report_in=executive_report_in, ))
def handle_executive_report_create( user_id: str, user_email: str, channel_id: str, incident_id: int, action: dict, config: SlackConversationConfiguration = None, db_session=None, slack_client=None, ): """Handles the creation of executive reports.""" executive_report_in = ExecutiveReportCreate( current_status=action["submission"]["current_status"], overview=action["submission"]["overview"], next_steps=action["submission"]["next_steps"], ) incident = incident_service.get(db_session=db_session, incident_id=incident_id) executive_report = report_flows.create_executive_report( user_email=user_email, incident_id=incident_id, executive_report_in=executive_report_in, db_session=db_session, ) # we let the user know that the report has been created send_feedack_to_user( incident.conversation.channel_id, incident.project.id, user_id, f"The executive report document has been created and can be found in the incident storage here: {executive_report.document.weblink}", db_session, ) # we let the user know that the report has been sent to the notifications group send_feedack_to_user( incident.conversation.channel_id, incident.project.id, user_id, f"The executive report has been emailed to the incident notifications group ({incident.notifications_group.email}).", db_session, )