Skip to content

Commit 0971281

Browse files
committed
docs: Add a migration document for V2
1 parent 6546693 commit 0971281

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ Then open http://127.0.0.1:8000/.
151151

152152
## Further Documentation
153153

154+
- [Migrate to a newer version of this library](https://github.com/loopwerk/django-generic-notifications/tree/main/docs/migrate.md)
154155
- [Customization: custom channels, frequencies, and email templates](https://github.com/loopwerk/django-generic-notifications/tree/main/docs/customizing.md)
155156
- [Performance considerations and tips](https://github.com/loopwerk/django-generic-notifications/tree/main/docs/performance.md)
156157
- [Notification grouping: prevent notification spam by grouping similar notifications together](https://github.com/loopwerk/django-generic-notifications/tree/main/docs/grouping.md)

docs/migrate.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Migrate from v1 to v2
2+
3+
Version two of django-generic-notifications has [a lot of improvements](https://github.com/loopwerk/django-generic-notifications/releases/tag/2.0.0), and some breaking changes in order to better support non-email digest channels. Most of these breaking changes will only affect you if you're writing custom channels or frequencies. If you only added custom notification types, then most changes won't affect you.
4+
5+
## Renamed classes and methods
6+
7+
- Renamed `NotificationChannel` -> `BaseChannel`
8+
- Renamed `NotificationFrequency` -> `BaseFrequency`
9+
- Renamed `EmailFrequency` model to `NotificationFrequency` model
10+
- Renamed `NotificationType.default_email_frequency` -> `NotificationType.default_frequency`
11+
- Renamed `NotificationType.set_email_frequency` -> `NotificationType.set_frequency`
12+
- Renamed `NotificationType.get_email_frequency` -> `NotificationType.get_frequency`
13+
- Renamed `NotificationType.reset_email_frequency_to_default` -> `NotificationType.reset_frequency_to_default`
14+
- Renamed `EmailChannel.send_email_now` -> `EmailChannel.send_now`
15+
- Renamed `EmailChannel.send_digest_emails` -> `EmailChannel.send_digest`
16+
17+
This should be a simple matter of find-and-replace.
18+
19+
## Renamed send_digest_emails command
20+
21+
The `send_digest_emails` management command was renamed `send_notification_digests`. This means you'll need to update your cronjob or however else you started the digest command.
22+
23+
## BaseChannel changes
24+
25+
The `process` method moved from individual channel implementations to the `BaseChannel` class, which now calls either the `send_now` or `send_digest` method. This means that if you wrote a custom `BaseChannel` subclass, that you most likely can remove the `process` method and move the logic to the `send_now` and/or `send_digest` methods. Check the provided `WebsiteChannel` and `EmailChannel` for details.
26+
27+
## User preference changes
28+
29+
The `get_notification_preferences` function now returns `notification_frequency` instead of `email_frequency`. If you make use of `get_notification_preferences` to build a preference UI, you'll most likely need to check your usage and do this rename.

0 commit comments

Comments
 (0)