Skip to content

Commit aac2b17

Browse files
feat(api): add postmortem_url field to incident serializer
Add postmortem_url field to the IncidentSerializer to expose the Confluence post-mortem page URL in the API response. The field returns: - The Confluence page URL if a post-mortem exists for the incident - null if no post-mortem has been created yet This allows API consumers to directly access the post-mortem documentation for incidents without additional requests.
1 parent 63332b2 commit aac2b17

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/firefighter/api/serializers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class IncidentSerializer(TaggitSerializer, serializers.ModelSerializer[Incident]
218218
status = serializers.SerializerMethodField()
219219
created_by = UserSerializer(read_only=True)
220220
slack_channel_name = serializers.SerializerMethodField()
221+
postmortem_url = serializers.SerializerMethodField()
221222

222223
created_by_email = CreatableSlugRelatedField[User](
223224
source="created_by",
@@ -252,6 +253,13 @@ def get_status(obj: Incident) -> str:
252253
def get_slack_channel_name(obj: Incident) -> str:
253254
return f"#{obj.slack_channel_name}" if obj.slack_channel_name else ""
254255

256+
@staticmethod
257+
def get_postmortem_url(obj: Incident) -> str | None:
258+
"""Return the Confluence post-mortem page URL if it exists."""
259+
if hasattr(obj, "postmortem_for"):
260+
return obj.postmortem_for.page_url
261+
return None
262+
255263
def create(self, validated_data: dict[str, Any]) -> Incident:
256264
return Incident.objects.declare(**validated_data)
257265

@@ -279,6 +287,7 @@ class Meta:
279287
"status",
280288
"slack_channel_name",
281289
"status_page_url",
290+
"postmortem_url",
282291
"status",
283292
"environment_id",
284293
"incident_category_id",

0 commit comments

Comments
 (0)