From bb5c182ad0ea9fa7eba6a1267f95160c6bfbfd31 Mon Sep 17 00:00:00 2001 From: Gabriel Dugny Date: Tue, 2 Jan 2024 16:47:29 +0100 Subject: [PATCH] fixup: accidentally removed a setting --- .../firefighter/settings/components/slack.py | 4 ++++ src/firefighter/raid/views/open_normal.py | 3 --- src/firefighter/slack/views/modals/open.py | 11 +++++++++-- .../slack/views/modals/opening/details/critical.py | 4 +++- src/firefighter/slack/views/modals/update_status.py | 5 +++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/firefighter/firefighter/settings/components/slack.py b/src/firefighter/firefighter/settings/components/slack.py index 29546f39..f72ad3d9 100644 --- a/src/firefighter/firefighter/settings/components/slack.py +++ b/src/firefighter/firefighter/settings/components/slack.py @@ -28,6 +28,10 @@ "SLACK_INCIDENT_HELP_GUIDE_URL", default=None ) "URL to add in the Slack help message (/incident help). Useful to point to your own documentation." +SLACK_SEVERITY_HELP_GUIDE_URL: str | None = config( + "SLACK_SEVERITY_HELP_GUIDE_URL", default=None +) +"URL to add in the form to choose the priority. Useful to point to your own documentation." SLACK_EMERGENCY_COMMUNICATION_GUIDE_URL: str | None = config( "SLACK_EMERGENCY_COMMUNICATION_GUIDE_URL", default=None ) diff --git a/src/firefighter/raid/views/open_normal.py b/src/firefighter/raid/views/open_normal.py index d9b0a3e4..abd3af60 100644 --- a/src/firefighter/raid/views/open_normal.py +++ b/src/firefighter/raid/views/open_normal.py @@ -3,7 +3,6 @@ import logging from typing import TYPE_CHECKING -from django.conf import settings from slack_sdk.models.blocks.basic_components import MarkdownTextObject from slack_sdk.models.blocks.blocks import ContextBlock @@ -23,8 +22,6 @@ logger = logging.getLogger(__name__) -SLACK_SEVERITY_HELP_GUIDE_URL: str = settings.SLACK_SEVERITY_HELP_GUIDE_URL - slack_fields: SlackFormAttributesDict = { "title": { "input": { diff --git a/src/firefighter/slack/views/modals/open.py b/src/firefighter/slack/views/modals/open.py index 789c9dfd..ab1dbe47 100644 --- a/src/firefighter/slack/views/modals/open.py +++ b/src/firefighter/slack/views/modals/open.py @@ -46,7 +46,7 @@ app = SlackApp() logger = logging.getLogger(__name__) -SLACK_SEVERITY_HELP_GUIDE_URL: str = settings.SLACK_SEVERITY_HELP_GUIDE_URL +SLACK_SEVERITY_HELP_GUIDE_URL: str | None = settings.SLACK_SEVERITY_HELP_GUIDE_URL INCIDENT_TYPES: dict[ResponseType, dict[str, dict[str, Any]]] = { @@ -411,7 +411,14 @@ def _build_response_type_blocks(open_incident_context: OpeningData) -> list[Bloc MarkdownTextObject( text=f"> {priority.emoji} Selected priority: {priority}" + ( - f"\n> Critical incidents are for *emergency* only, <{SLACK_SEVERITY_HELP_GUIDE_URL}|learn more>." + ( + "\n> Critical incidents are for *emergency* only" + + ( + f"<{SLACK_SEVERITY_HELP_GUIDE_URL}|learn more>" + if SLACK_SEVERITY_HELP_GUIDE_URL + else "" + "." + ) + ) if selected_response_type == "critical" else "" ) diff --git a/src/firefighter/slack/views/modals/opening/details/critical.py b/src/firefighter/slack/views/modals/opening/details/critical.py index 28546058..c0301a5e 100644 --- a/src/firefighter/slack/views/modals/opening/details/critical.py +++ b/src/firefighter/slack/views/modals/opening/details/critical.py @@ -50,7 +50,9 @@ class CreateIncidentFormSlack(CreateIncidentForm): "widget": { "post_block": SectionBlock( text=f"_<{settings.SLACK_SEVERITY_HELP_GUIDE_URL}|How to choose the priority?>_" - ), + ) + if settings.SLACK_SEVERITY_HELP_GUIDE_URL + else None, "label_from_instance": lambda obj: f"{obj.emoji} {obj.name} - {obj.description}", }, }, diff --git a/src/firefighter/slack/views/modals/update_status.py b/src/firefighter/slack/views/modals/update_status.py index b2db99e0..3d907e40 100644 --- a/src/firefighter/slack/views/modals/update_status.py +++ b/src/firefighter/slack/views/modals/update_status.py @@ -43,8 +43,9 @@ class UpdateStatusFormSlack(UpdateStatusForm): "widget": { "post_block": SectionBlock( text=f"_<{settings.SLACK_SEVERITY_HELP_GUIDE_URL}|How to choose the priority?>_" - ), - # XXX Link to new Priority doc + ) + if settings.SLACK_SEVERITY_HELP_GUIDE_URL + else None, "label_from_instance": priority_label, }, },