Skip to content

Commit 5efb79d

Browse files
committed
fix: withdrawal notifications broken — dead import silently swallowed
The withdraw_submission view imported the removed legacy function _notify_workflow_notification_with_cadence from workflow_engine. A bare 'except Exception' silently swallowed the ImportError, so form_withdrawn notification rules never fired for any form. Replace with _dispatch_notification_rules(submission, 'form_withdrawn') which is the unified notification dispatch used by all other events. Bump version to 0.61.1.
1 parent d025b07 commit 5efb79d

4 files changed

Lines changed: 33 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.61.1] - 2026-04-02
11+
12+
### Fixed
13+
- **Withdrawal notifications broken**`withdraw_submission` view imported the
14+
removed legacy function `_notify_workflow_notification_with_cadence`; a bare
15+
`except Exception` silently swallowed the `ImportError`, so `form_withdrawn`
16+
notification rules never fired for any form. Replaced with a direct call to
17+
`_dispatch_notification_rules(submission, "form_withdrawn")`.
18+
1019
## [0.61.0] - 2026-04-02
1120

1221
### Added

django_forms_workflows/views.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,18 +2235,10 @@ def withdraw_submission(request, submission_id):
22352235
comments="Submission withdrawn by submitter",
22362236
)
22372237

2238-
# Send withdrawal notifications — respects notification_cadence.
2239-
try:
2240-
from .workflow_engine import _notify_workflow_notification_with_cadence
2238+
# Dispatch form_withdrawn notification rules.
2239+
from .workflow_engine import _dispatch_notification_rules
22412240

2242-
_notify_workflow_notification_with_cadence(
2243-
submission, "withdrawal_notification"
2244-
)
2245-
except Exception:
2246-
logger.warning(
2247-
"Could not dispatch withdrawal notifications for submission %s",
2248-
submission.id,
2249-
)
2241+
_dispatch_notification_rules(submission, "form_withdrawn")
22502242

22512243
messages.success(request, "Submission withdrawn successfully.")
22522244
return redirect("forms_workflows:my_submissions")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-forms-workflows"
3-
version = "0.61.0"
3+
version = "0.61.1"
44
description = "Enterprise-grade, database-driven form builder with approval workflows and external data integration"
55
license = "LGPL-3.0-only"
66
readme = "README.md"

tests/test_views.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
from datetime import timedelta
6+
from unittest import mock
67

78
import pytest
89
from django.test import Client
@@ -170,6 +171,25 @@ def test_cannot_withdraw_approved(self, auth_client, form_with_fields, user):
170171
sub.refresh_from_db()
171172
assert sub.status == "approved" # Should not change
172173

174+
def test_withdraw_dispatches_form_withdrawn_notification(
175+
self, auth_client, form_with_fields, user
176+
):
177+
"""Withdrawal must call _dispatch_notification_rules with 'form_withdrawn'."""
178+
sub = FormSubmission.objects.create(
179+
form_definition=form_with_fields,
180+
submitter=user,
181+
form_data={"full_name": "Test"},
182+
status="pending_approval",
183+
)
184+
url = reverse("forms_workflows:withdraw_submission", args=[sub.pk])
185+
with mock.patch(
186+
"django_forms_workflows.workflow_engine._dispatch_notification_rules"
187+
) as mock_dispatch:
188+
auth_client.post(url)
189+
mock_dispatch.assert_called_once_with(mock.ANY, "form_withdrawn")
190+
# Verify it was called with the right submission
191+
assert mock_dispatch.call_args[0][0].id == sub.id
192+
173193

174194
# ── submission_detail ────────────────────────────────────────────────────
175195

0 commit comments

Comments
 (0)