Skip to content

Commit 6b72956

Browse files
committed
docs: Document notification email template context
1 parent f2bf4a4 commit 6b72956

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

docs/customizing.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,23 @@ If notification-type specific templates are not found, the system will fall back
139139

140140
This allows you to create generic templates that work for all notification types while still having the flexibility to create specific templates for certain types.
141141

142+
**Template context:**
143+
144+
- `recipient`: The recipient user (same as `notification.recipient`)
145+
- `notification`: The `Notification` instance
146+
- `actor`: The actor who triggered the notification (if any)
147+
- `target`: The target object of the notification (if any)
148+
142149
### Digest emails
143150

144151
- `notifications/email/digest/subject.txt`
145152
- `notifications/email/digest/message.html`
146153
- `notifications/email/digest/message.txt`
154+
155+
**Template context:**
156+
157+
- `recipient`: The recipient user
158+
- `notifications`: Queryset of all notifications in the digest
159+
- `notifications_by_type`: Dictionary grouping notifications by their type
160+
- `count`: Total number of notifications in the digest
161+
- `frequency`: The frequency instance (e.g., `DailyFrequency`)

generic_notifications/channels.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def send_now(self, notification: "Notification") -> None:
166166
context = {
167167
"notification": notification,
168168
"user": notification.recipient,
169+
"recipient": notification.recipient,
169170
"actor": notification.actor,
170171
"target": notification.target,
171172
}
@@ -249,6 +250,7 @@ def send_digest(self, notifications: "QuerySet[Notification]", frequency: type[B
249250

250251
context = {
251252
"user": user,
253+
"recipient": user,
252254
"notifications": notifications,
253255
"notifications_by_type": notifications_by_type,
254256
"count": notifications.count(),

0 commit comments

Comments
 (0)