Commit 8a92686
committed
feat: custom body templates render reviewer comments + auto-detect finalizing task
Two new pieces of context for any NotificationRule body_template
string (also added to the file-template context, harmless extras):
- `task` — the finalizing/rejecting ApprovalTask. For workflow_approved
and workflow_denied this is auto-detected from the submission's
task history when no explicit task_id is passed: latest-approved
task for workflow_approved, latest-rejected task for workflow_denied.
So `{{ task.comments }}` and `{{ task.workflow_stage.name }}` work in
custom bodies for those events without the engine threading the task
through, and the admin "Retry failed" action gets the right task too.
- `public_comments` — denormalized list of
{stage_name, status, actor, comment} dicts for every approved/rejected
task with a non-empty comment, ordered by workflow flow
(stage_number → step_number → completed_at). Lets a custom body do
`{% for c in public_comments %}{{ c.stage_name }}: {{ c.comment }}
{% endfor %}` without iterating the ApprovalTask model. Pending
tasks and tasks without comments are excluded.
Also drops the over-aggressive _skip_stage_groups early-out in
_collect_notification_recipients. The per-stage filter shipped in
0.74.9 (assigned_group set, assigned_to NULL) is strictly more
correct: for the per-task approval_request use case it produces the
same outcome as the early-out (the eff_stage's task with assigned_to
set is excluded by the filter, so no group recipients), and for
workflow-level events it correctly considers OTHER stages on the
workflow that the early-out would have suppressed once auto-detection
picks a finalizing task that happens to be dynamic-assigned.
4 new tests cover:
- public_comments loop renders in workflow order
- {{ task.comments }} / {{ task.workflow_stage.name }} resolve via
auto-detect for workflow_denied
- Symmetric auto-detect for workflow_approved
- public_comments excludes pending tasks and empty-comment tasks
(Reassign view fix shipped in the prior commit.)1 parent 1d6d0a2 commit 8a92686
4 files changed
Lines changed: 357 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
10 | 54 | | |
11 | 55 | | |
12 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1176 | 1176 | | |
1177 | 1177 | | |
1178 | 1178 | | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
1193 | 1190 | | |
1194 | 1191 | | |
1195 | 1192 | | |
| |||
1361 | 1358 | | |
1362 | 1359 | | |
1363 | 1360 | | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
1364 | 1387 | | |
1365 | 1388 | | |
1366 | 1389 | | |
| |||
1377 | 1400 | | |
1378 | 1401 | | |
1379 | 1402 | | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
1380 | 1431 | | |
1381 | 1432 | | |
1382 | 1433 | | |
| |||
1540 | 1591 | | |
1541 | 1592 | | |
1542 | 1593 | | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
1543 | 1600 | | |
1544 | 1601 | | |
1545 | 1602 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments