def update_impact(incident: Incident, user_id: str, message: str): # Easy case. No impact currently and one has been provided if message and not incident.impact: incident.impact = message incident.save() return True, f"{IMPACT_UPDATED_TITLE}{message}" # Either no new impact has been provided, or one already exists msg = block_kit.Message() msg.add_block( block_kit.Section( block_id="update", text=block_kit.Text( f"{CURRENT_TITLE}{incident.impact or NO_IMPACT_TEXT}"), accessory=block_kit.Button(CHANGE_BUTTON_TEXT, UPDATE_CURRENT_IMPACT_ACTION, value=incident.pk), )) # if the user has supplied a message, provide the option for them to set it without # retyping in the dialog if message: msg.add_block( block_kit.Section( block_id=PROPOSED_MESSAGE_BLOCK_ID, text=block_kit.Text(f"{PROPOSED_TITLE}{message}"), accessory=block_kit.Button(ACCEPT_PROPOSED_TEXT, SET_NEW_IMPACT_ACTION, value=incident.pk), )) comms_channel = CommsChannel.objects.get(incident=incident) msg.send(comms_channel.channel_id) return True, None
def update_impact(incident: Incident, user_id: str, message: str): incident.impact = message incident.save() return True, None